diff --git a/blazarclient/command.py b/blazarclient/command.py index 459b090..9bff44f 100644 --- a/blazarclient/command.py +++ b/blazarclient/command.py @@ -282,12 +282,6 @@ class ShowCommand(BlazarCommand, show.ShowOne): def get_parser(self, prog_name): parser = super(ShowCommand, self).get_parser(prog_name) - if self.allow_names: - help_str = 'ID or name of %s to look up' - else: - help_str = 'ID of %s to look up' - parser.add_argument('id', metavar=self.resource.upper(), - help=help_str % self.resource) return parser def get_data(self, parsed_args): diff --git a/blazarclient/v1/shell_commands/floatingips.py b/blazarclient/v1/shell_commands/floatingips.py index b93e91e..90720d9 100644 --- a/blazarclient/v1/shell_commands/floatingips.py +++ b/blazarclient/v1/shell_commands/floatingips.py @@ -41,6 +41,16 @@ class ShowFloatingIP(command.ShowCommand): json_indent = 4 log = logging.getLogger(__name__ + '.ShowFloatingIP') + def get_parser(self, prog_name): + parser = super(ShowFloatingIP, self).get_parser(prog_name) + if self.allow_names: + help_str = 'ID or name of %s to look up' + else: + help_str = 'ID of %s to look up' + parser.add_argument('id', metavar=self.resource.upper(), + help=help_str % self.resource) + return parser + class CreateFloatingIP(command.CreateCommand): """Create a floating IP.""" diff --git a/blazarclient/v1/shell_commands/hosts.py b/blazarclient/v1/shell_commands/hosts.py index 250c376..c9e44a1 100644 --- a/blazarclient/v1/shell_commands/hosts.py +++ b/blazarclient/v1/shell_commands/hosts.py @@ -46,6 +46,16 @@ class ShowHost(command.ShowCommand): id_pattern = HOST_ID_PATTERN log = logging.getLogger(__name__ + '.ShowHost') + def get_parser(self, prog_name): + parser = super(ShowHost, self).get_parser(prog_name) + if self.allow_names: + help_str = 'ID or name of %s to look up' + else: + help_str = 'ID of %s to look up' + parser.add_argument('id', metavar=self.resource.upper(), + help=help_str % self.resource) + return parser + class CreateHost(command.CreateCommand): """Create a host.""" diff --git a/blazarclient/v1/shell_commands/leases.py b/blazarclient/v1/shell_commands/leases.py index 9fe3e36..2bd4c2d 100644 --- a/blazarclient/v1/shell_commands/leases.py +++ b/blazarclient/v1/shell_commands/leases.py @@ -90,6 +90,16 @@ class ShowLease(command.ShowCommand): json_indent = 4 log = logging.getLogger(__name__ + '.ShowLease') + def get_parser(self, prog_name): + parser = super(ShowLease, self).get_parser(prog_name) + if self.allow_names: + help_str = 'ID or name of %s to look up' + else: + help_str = 'ID of %s to look up' + parser.add_argument('id', metavar=self.resource.upper(), + help=help_str % self.resource) + return parser + class CreateLeaseBase(command.CreateCommand): """Create a lease.""" diff --git a/releasenotes/notes/separate-id-parser-argument-from-showcommand-ce92d0c52dd1963e.yaml b/releasenotes/notes/separate-id-parser-argument-from-showcommand-ce92d0c52dd1963e.yaml new file mode 100644 index 0000000..fa66f5f --- /dev/null +++ b/releasenotes/notes/separate-id-parser-argument-from-showcommand-ce92d0c52dd1963e.yaml @@ -0,0 +1,6 @@ +--- +other: + - | + The ID parser argument is moved from the ShowCommand class to each resource + class. This allows the ordering of arguments to be fully customised, + instead of requiring the ID to come first.