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

update error message for invalid subcommand usage #1029

Merged
merged 2 commits into from
Aug 15, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/dcoscli/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def wrapper(*args, **kwargs):
try:
result = func(*args, **kwargs)
except docopt.DocoptExit as e:
emitter.publish("Command not recognized\n")
emitter.publish("Invalid subcommand usage\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the standard response? What do other subcommands say here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be this same message for all subcommands if they are misused (auth, job, etc.), this is only different for subcommands which have their own binary, where the behaviour depends on the executable I think.

Some examples :

(dcos-cli/cli) ➜  cli git:(dcos-community-95) dcos auth
Invalid subcommand usage

Usage:
    dcos auth --help
    dcos auth --info
    dcos auth --version
    dcos auth list-providers [--json]
    dcos auth login
        [--provider=<provider_id>] [--username=<username>]
        [--password=<password> | --password-file=<password_file>
        | --password-env=<password_env> | --private-key=<key_path>]
    dcos auth logout
(dcos-cli/cli) ➜  cli git:(dcos-community-95) dcos job --invalid
Invalid subcommand usage

Usage:
        dcos job --config-schema
        dcos job --help
        dcos job --info
        dcos job --version
        dcos job add <job-file>
        dcos job remove <job-id> [--stop-current-job-runs]
        dcos job show <job-id>
        dcos job update <job-file>
        dcos job kill <job-id> [<run-id>][--all]
        dcos job run <job-id> [--json]
        dcos job list [--json]
        dcos job schedule add <job-id> <schedule-file>
        dcos job schedule show <job-id> [--json]
        dcos job schedule remove <job-id> <schedule-id>
        dcos job schedule update <job-id> <schedule-file>
        dcos job show runs <job-id> [--run-id <run-id>][--json][--q]
        dcos job history <job-id> [--json][--show-failures]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. It would be good to have a common string abstracted out for this, but we can leave this as future work.

emitter.publish(e)
return 1
return result
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/integrations/test_experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def test_package_build_where_build_definition_has_badly_formed_reference():
stderr=stderr)


def test_package_add_argument_exclussion():
def test_package_add_argument_exclusion():
command = command_base + ['package', 'add',
'--dcos-package', runnable_package_path(1),
'--package-version', '3.0']
Expand All @@ -194,7 +194,7 @@ def test_package_add_argument_exclussion():
assert err == b''

stdout = out.decode()
not_recognized = 'Command not recognized'
not_recognized = 'Invalid subcommand usage'
assert not_recognized in stdout


Expand Down
4 changes: 2 additions & 2 deletions cli/tests/integrations/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_show_job_with_blank_jobname():
['dcos', 'job', 'show'])

assert returncode == 1
assert "Command not recognized" in stdout.decode('utf-8')
assert "Invalid subcommand usage" in stdout.decode('utf-8')


def test_show_job_with_invalid_jobname():
Expand All @@ -103,7 +103,7 @@ def test_show_schedule_blank_jobname():
['dcos', 'job', 'schedule', 'show'])

assert returncode == 1
assert stdout.decode('utf-8').startswith('Command not recognized')
assert stdout.decode('utf-8').startswith('Invalid subcommand usage')


def test_show_schedule_invalid_jobname():
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/integrations/test_marathon_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_scale_group_when_scale_factor_negative():
with group(SCALE_GROUP, 'scale-group'):
returncode, stdout, stderr = exec_command(
['dcos', 'marathon', 'group', 'scale', 'scale-group', '-2'])
assert b'Command not recognized' in stdout
assert b'Invalid subcommand usage' in stdout
assert returncode == 1


Expand Down
2 changes: 1 addition & 1 deletion cli/tests/integrations/test_marathon_pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_pod_update_does_not_support_properties():
returncode, stdout, stderr = exec_command(cmd)

assert returncode == 1
assert stdout.startswith(b'Command not recognized\n')
assert stdout.startswith(b'Invalid subcommand usage\n')
assert stderr == b''


Expand Down