diff --git a/wpull/application/options.py b/wpull/application/options.py index aea41cc6..e3838d00 100644 --- a/wpull/application/options.py +++ b/wpull/application/options.py @@ -1168,6 +1168,7 @@ def _add_accept_args(self): '-R', '--reject', metavar='LIST', + type=self.comma_list, help=_('don’t download files with suffix in LIST'), ) group.add_argument( diff --git a/wpull/application/options_test.py b/wpull/application/options_test.py index 44a99285..35478cf1 100644 --- a/wpull/application/options_test.py +++ b/wpull/application/options_test.py @@ -39,3 +39,32 @@ def test_exit(status=0, message=None): self.assertEqual(2, error.args[0]) else: self.assertTrue(False) + + def test_comma_list_args(self): + arg_item_list = [ + '--accept', '--reject', + '--domains', '--exclude-domains', + '--hostnames', '--exclude-hostnames', + '--follow-tags', '--ignore-tags', + '--include-directories', '--exclude-directories', + '--proxy-domains', '--proxy-exclude-domains', + '--proxy-hostnames', '--proxy-exclude-hostnames', + ] + arg_dest_list = [ + 'accept', 'reject', + 'domains', 'exclude_domains', + 'hostnames', 'exclude_hostnames', + 'follow_tags', 'ignore_tags', + 'include_directories', 'exclude_directories', + 'proxy_domains', 'proxy_exclude_domains', + 'proxy_hostnames', 'proxy_exclude_hostnames', + ] + + cli_input = 'item1,item2,item3' + expected_value = ['item1', 'item2', 'item3'] + + for arg_item, arg_dest in zip(arg_item_list, arg_dest_list): + arg_parser = AppArgumentParser() + + args = arg_parser.parse_args(['http://example.invalid'] + [arg_item, cli_input]) + self.assertEqual(expected_value, vars(args)[arg_dest])