From 96bcfe012b3b1659dbd0244ac6c4a43dfb5328d6 Mon Sep 17 00:00:00 2001 From: Eric Lin Date: Sat, 6 Oct 2018 17:17:17 +0000 Subject: Added handling of nargs=argparse.REMAINDER in both AutoCompleter and ArgparseFunctor Should correctly force all subsequent arguments to go to the REMAINDER argument once it is detected. Re-arranged the command generation in ArgparseFunctor to print flag arguments before positionals Also forces the remainder arguments to always be last. --- examples/tab_autocompletion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/tab_autocompletion.py b/examples/tab_autocompletion.py index 6a2e683e..6be7f0c8 100755 --- a/examples/tab_autocompletion.py +++ b/examples/tab_autocompletion.py @@ -336,7 +336,7 @@ class TabCompleteExample(cmd2.Cmd): movies_add_parser.add_argument('title', help='Movie Title') movies_add_parser.add_argument('rating', help='Movie Rating', choices=ratings_types) movies_add_parser.add_argument('-d', '--director', help='Director', nargs=(1, 2), required=True) - movies_add_parser.add_argument('actor', help='Actors', nargs='*') + movies_add_parser.add_argument('actor', help='Actors', nargs=argparse.REMAINDER) movies_delete_parser = movies_commands_subparsers.add_parser('delete') movies_delete_movie_id = movies_delete_parser.add_argument('movie_id', help='Movie ID') -- cgit v1.2.1