From bf2a0d3caf8256d60f1691f2c15d41a63f432c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Tue, 22 Jan 2019 00:00:00 +0000 Subject: [PATCH] cli_function: print nargs positional args properly --- cli_function.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cli_function.py b/cli_function.py index b343c8c..89f0f5b 100755 --- a/cli_function.py +++ b/cli_function.py @@ -284,7 +284,7 @@ class CliFunction: bisect.insort(options, val) else: if type(value) is list: - positional_dict[key] = [tuple(v,) for v in value] + positional_dict[key] = [tuple([v]) for v in value] else: positional_dict[key] = [(str(value),)] # Python built-in data structures suck. @@ -429,10 +429,8 @@ amazing function! assert one_cli_function.get_cli(pos_mandatory=1, asdf='B') == [('--asdf', 'B'), ('--bool-cli',), ('1',)] assert one_cli_function.get_cli(pos_mandatory=1, asdf='B', qwer='R') == [('--asdf', 'B'), ('--bool-cli',), ('--qwer', 'R'), ('1',)] assert one_cli_function.get_cli(pos_mandatory=1, bool=False) == [('--bool',), ('--bool-cli',), ('1',)] - assert one_cli_function.get_cli(pos_mandatory=1, pos_optional=2, args_star=['3', '4']) == [('--bool-cli',), ('1',), ('2',), ('3',), ('4',)] + assert one_cli_function.get_cli(pos_mandatory=1, pos_optional=2, args_star=['asdf', 'qwer']) == [('--bool-cli',), ('1',), ('2',), ('asdf',), ('qwer',)] assert one_cli_function.get_cli(pos_mandatory=1, append=['2', '3']) == [('--append', '2'), ('--append', '3',), ('--bool-cli',), ('1',)] - print(one_cli_function.get_cli(pos_mandatory=1, args_star=['asdf', 'qwer'])) - assert one_cli_function.get_cli(pos_mandatory=1, args_star=['asdf', 'qwer']) == [('--bool-cli',), ('1',), ('asdf',), ('qwer',),] if len(sys.argv) > 1: # CLI call with argv command line arguments.