remove -s alias for --sort-columns
Cliff normally uses short option name aliases which are global in to the CLI. We want commands to not use them due to the limited number and ease of collision. However this one was already in use by a well-known plugin so we will not take it. Change-Id: Id348dad450b52716b82d7852d6378ecc48808f26 Closes-Bug: #1743578 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
a114aabbf4
commit
134ebd4a9a
|
@ -50,7 +50,7 @@ class Lister(display.DisplayCommandBase):
|
|||
parser = super(Lister, self).get_parser(prog_name)
|
||||
group = self._formatter_group
|
||||
group.add_argument(
|
||||
'-s', '--sort-column',
|
||||
'--sort-column',
|
||||
action='append',
|
||||
default=[],
|
||||
dest='sort_columns',
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import argparse
|
||||
import functools
|
||||
|
||||
from cliff import command
|
||||
|
@ -42,6 +43,10 @@ class TestCommand(command.Command):
|
|||
help="The quick brown fox jumps "
|
||||
"over the lazy dog.",
|
||||
)
|
||||
parser.add_argument(
|
||||
'-z',
|
||||
help='used in TestArgumentParser',
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
@ -128,3 +133,18 @@ class TestHelp(base.TestBase):
|
|||
width=78,
|
||||
)
|
||||
self.assertIn(expected_help_message, parser.format_help())
|
||||
|
||||
|
||||
class TestArgumentParser(base.TestBase):
|
||||
|
||||
def test_option_name_collision(self):
|
||||
cmd = TestCommand(None, None)
|
||||
parser = cmd.get_parser('NAME')
|
||||
# We should have an exception registering an option with a
|
||||
# name that already exists because we do not want commands to
|
||||
# override global options.
|
||||
self.assertRaises(
|
||||
argparse.ArgumentError,
|
||||
parser.add_argument,
|
||||
'-z',
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue