action-hero
action-hero copied to clipboard
Question: How to specify argparse "required=True"? (minor missing pren on main page)
hi, Love the idea and work behind the package, but don't know how to specify that something is required. Python 3.7 argparse has an optional "required" to say the "option" is actually required. I would like to have
parser.add_argument( "--file",
action=PipelineAction,
action_values=[
RequiredAction,
FileExistsAction,
FileIsReadableAction
]
)
Is there any way to group all required items together in the help portion? I have used the package pathlib and it seems very nice. Have you considered using it to define path objects sort of like
on the main git hub page this example is missing a closing round bracket:
parser.add_argument(
"--file",
action=PipelineAction,
action_values=[
FileExistsAction,
(FileHasExtensionAction, ["md", "markdown"]),
FileIsWritableAction,
FileIsEmptyAction
]
I am just a retired geek so this is not a big problem but I do like the idea of being able to have consistent and concise. To me I do not want to put the "else: # Print usage if no arguments were given" as part of my code. I want this to be build into action_hero. Thanks.