From d6dec68b6801dcc6bfdfeb1bdcbb6c69e4459fc4 Mon Sep 17 00:00:00 2001 From: Abhishek Dasgupta Date: Mon, 4 Mar 2024 22:18:33 +0000 Subject: [PATCH] Passing the --command option requires --scheduler to be set --- cats/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cats/__init__.py b/cats/__init__.py index 8dbddfb..4782edc 100644 --- a/cats/__init__.py +++ b/cats/__init__.py @@ -64,7 +64,7 @@ def parse_arguments(): and can be the easest way to use cats to minimise the carbon intensity of calculations on smaller computers. For example, the above calculation can be scheduled by running: - mycommand | at -t `cats -d 90 --loc OX1 -s at` + cats -d 90 --loc OX1 -s at -c 'mycommand' """ parser = ArgumentParser(prog="cats", description=description_text, epilog=example_text) @@ -88,7 +88,7 @@ def parse_arguments(): "Default: `carbonintensity.org.uk`." ) parser.add_argument( - "-c", "--command", help="Command to schedule" + "-c", "--command", help="Command to schedule, requires --scheduler to be set" ) parser.add_argument( "--dateformat", help="Output date format in strftime(3) format or one of the supported schedulers ('at')." @@ -165,6 +165,10 @@ def schedule_at(output: CATSOutput, args: list[str]) -> None: def main(arguments=None): parser = parse_arguments() args = parser.parse_args(arguments) + if args.command and not args.scheduler: + print("cats: To run a command with the -c or --command option, you must\n" + " specify the scheduler with the -s or --scheduler option") + sys.exit(1) ################################## ## Validate and clean arguments ##