Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error out for remaining args in custom commands #886

Merged
merged 1 commit into from
Aug 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions awscli/clidriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def main(self, args=None):
self._handle_top_level_args(parsed_args)
return command_table[parsed_args.command](remaining, parsed_args)
except UnknownArgumentError as e:
sys.stderr.write("\n")
sys.stderr.write(str(e) + '\n')
return 255
except NoRegionError as e:
Expand Down
2 changes: 2 additions & 0 deletions awscli/customizations/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def __call__(self, args, parsed_globals):
elif getattr(parsed_args, 'subcommand', None) is None:
# No subcommand was specified so call the main
# function for this top level command.
if remaining:
raise ValueError("Unknown options: %s" % ','.join(remaining))
return self._run_main(parsed_args, parsed_globals)
else:
return subcommand_table[parsed_args.subcommand](remaining,
Expand Down
8 changes: 5 additions & 3 deletions tests/unit/customizations/s3/test_ls_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from awscli.testutils import BaseAWSCommandParamsTest
from dateutil import parser, tz


class TestLSCommand(BaseAWSCommandParamsTest):

def test_operations_used_in_recursive_list(self):
Expand All @@ -34,6 +35,7 @@ def test_operations_used_in_recursive_list(self):
self.assertEqual(
stdout, '%s 100 foo/bar.txt\n'%time_local.strftime('%Y-%m-%d %H:%M:%S'))


if __name__ == "__main__":
unittest.main()
def test_errors_out_with_extra_arguments(self):
stderr = self.run_cmd('s3 ls --extra-argument-foo', expected_rc=255)[1]
self.assertIn('Unknown options', stderr)
self.assertIn('--extra-argument-foo', stderr)