Skip to content

Commit

Permalink
Exit gracefully with informative message when no arguments are passed
Browse files Browse the repository at this point in the history
Summary:
Alternatively, we could set required=True in the click argument. This would give:
```
➜  Desktop dagster schedule start
Usage: dagster schedule start [OPTIONS] SCHEDULE_NAME...
Try "dagster schedule start --help" for help.

Error: Missing argument "SCHEDULE_NAME...".
```
See: https://click.palletsprojects.com/en/7.x/arguments/#variadic-arguments

Test Plan: Manual

Reviewers: sashank, prha

Reviewed By: sashank

Differential Revision: https://dagster.phacility.com/D2351
  • Loading branch information
mgasner committed Mar 30, 2020
1 parent 378eea2 commit c1eba8e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion python_modules/dagster/dagster/cli/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,17 @@ def extract_schedule_name(schedule_name):


@click.command(name='start', help="Start an existing schedule")
@click.argument('schedule_name', nargs=-1)
@click.argument('schedule_name', nargs=-1) # , required=True)
@click.option('--start-all', help="start all schedules", is_flag=True, default=False)
@repository_target_argument
def schedule_start_command(schedule_name, start_all, **kwargs):
schedule_name = extract_schedule_name(schedule_name)
if schedule_name is None and start_all is False:
print(
'Noop: dagster schedule start was called without any arguments specifying which '
'schedules to start. Pass a schedule name or the --start-all flag to start schedules.'
)
return
return execute_start_command(schedule_name, start_all, kwargs, click.echo)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,17 @@ def test_schedules_start_and_stop(_patch_scheduler_instance):
assert 'Stopped schedule foo_schedule\n' == result.output


def test_schedules_start_empty(_patch_scheduler_instance):
runner = CliRunner()

result = runner.invoke(
schedule_start_command, ['-y', file_relative_path(__file__, 'repository_file.yaml')],
)

assert result.exit_code == 0
assert 'Noop: dagster schedule start was called without any arguments' in result.output


def test_schedules_start_all(_patch_scheduler_instance):
runner = CliRunner()

Expand Down

0 comments on commit c1eba8e

Please sign in to comment.