Separate ID parser argument from ShowCommand
Move the ID parser argument from the base ShowCommand class to the resource classes. This allows us to define arguments in any order, instead of requiring the ID to be first. Change-Id: I8929e631562dc1ed5cd78f71e59517aa50429aca
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -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.
|
||||
Reference in New Issue
Block a user