Added code to detect if a mode is given.

This commit is contained in:
Jamie Hardt
2024-06-30 13:26:09 -07:00
parent 39d0e7c6f0
commit af10ed91cc

View File

@@ -58,7 +58,7 @@ def create_batch_list(command_file: str):
def main(): def main():
op = OptionParser(usage="%prog [-c] [-e] [-W] [options]") op = OptionParser(usage="%prog (-c | -e | -W) [options]")
op.add_option('-c', '--create', default=False, op.add_option('-c', '--create', default=False,
action='store_true', action='store_true',
@@ -97,19 +97,27 @@ def main():
exit(0) exit(0)
mode_given = False
if options.path is not None: if options.path is not None:
os.chdir(options.path) os.chdir(options.path)
if options.create: if options.create:
mode_given = True
create_batch_list(options.batchfile) create_batch_list(options.batchfile)
if options.edit: if options.edit:
mode_given = True
editor_command = [os.getenv('EDITOR'), options.batchfile] editor_command = [os.getenv('EDITOR'), options.batchfile]
run(editor_command) run(editor_command)
if options.write: if options.write:
mode_given = True
execute_batch_list(options.batchfile, dry_run=options.dry_run) execute_batch_list(options.batchfile, dry_run=options.dry_run)
if mode_given == False:
op.print_usage()
exit(-1)
if __name__ == "__main__": if __name__ == "__main__":
main() main()