Skip to content

Commit

Permalink
Passing the --command option requires --scheduler to be set
Browse files Browse the repository at this point in the history
  • Loading branch information
abhidg committed Mar 4, 2024
1 parent 9e78711 commit d6dec68
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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')."
Expand Down Expand Up @@ -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 ##
Expand Down

0 comments on commit d6dec68

Please sign in to comment.