There are a couple of instances in the GeoIPS CLI where we'd like to apply some scope to arguments available to a certain command but is currently not implemented, or if it is, it's done in a hacky way. For example, we'd like to share arguments amongst all commands for --log-level, and possibly some other arguments that would apply to any command. There are also instances where we'd like to share common arguments amongst a group of commands. Currently, we share arguments amongst list commands via a GeoipsListCommon class. We add arguments to this class, and when initializing all list commands such as GeoipsListPackages, GeoipsListPlugins, etc. we add GeoipsListCommon as it's parent so they all inherit those shared arguments.
This likely could be made simpler by making use of argparse.ArgumentParser.parse_known_args command. This will allow parsing arguments that are known at the time of execution rather than at the end of initialization. By using this in a clever way, we can add global arguments to all commands and shared arguments by the group of commands. This way we can more easily control the scope of a command argument.
Background and Motivation
This issue stems from these two comments (1 : 2) on PR #465.
Requested Update
Description
There are a couple of instances in the GeoIPS CLI where we'd like to apply some scope to arguments available to a certain command but is currently not implemented, or if it is, it's done in a hacky way. For example, we'd like to share arguments amongst all commands for
--log-level
, and possibly some other arguments that would apply to any command. There are also instances where we'd like to share common arguments amongst a group of commands. Currently, we share arguments amongstlist
commands via aGeoipsListCommon
class. We add arguments to this class, and when initializing all list commands such asGeoipsListPackages
,GeoipsListPlugins
, etc. we addGeoipsListCommon
as it's parent so they all inherit those shared arguments.This likely could be made simpler by making use of
argparse.ArgumentParser.parse_known_args
command. This will allow parsing arguments that are known at the time of execution rather than at the end of initialization. By using this in a clever way, we can add global arguments to all commands and shared arguments by the group of commands. This way we can more easily control the scope of a command argument.Background and Motivation
This issue stems from these two comments (1 : 2) on PR #465.
Code to demonstrate issue
geoips.commandline.geoips_command:GeoipsCommand:__init__
geoips.commandline.geoips_command:GeoipsListCommon
Checklist for Completion
argparse.ArgumentParser.parse_known_args
to:GeoipsListCommon
class and the functionality that makes use of it