-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Argparse flow is first value conversion (validate and convert), then action invocation (store it). ParseNonblockingStdin is an action which is actually a type arg- it converts - into a stream of arguments to inject.
The point is, it moves the parse time validation of each argument item out of the normal argparse flow. My rough thought is it should be this:
scan.add_argument(
"targets",
metavar="TARGET",
nargs="*",
type=arghparse.ParseNonblockingStdin(actual_value_parser),
help="if not given, scan the repo. If given, limit scans to pkgs matching extended atom syntax",
)
Interpose the check for -- if it's that, then expand it out into a sequence, then feed that through the actual validation.
This may have to be done strictly through action if type isn't invoked for the total values, which I'm fairly sure it's not.
Point is: the type conversion should be specifiable directly within the add_argument, and the API of that shim should enable it. The code I've seen using this is using the finalizer system (delayed parsing) which is a beast best not used for things like atom parsing- pkgcheck scan is that example.