diff options
author | Jackson Taylor <jackson@jacksontaylor.xyz> | 2022-08-08 07:43:59 -0400 |
---|---|---|
committer | Jackson Taylor <jackson@jacksontaylor.xyz> | 2022-08-08 07:43:59 -0400 |
commit | 930b8478d569f74f6153ac522c9bdefa450ecea7 (patch) | |
tree | 76989ba26da02daf5ab869f4eee6c41d159db808 | |
parent | 187e7927ba0b57e449257aa914ad05c5b977d67c (diff) |
Handle command line option misuse
You can't pass a url and a file in the same invocation, so we print out
the usage and stop.
-rwxr-xr-x | jamos | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -75,6 +75,16 @@ def get_command_line_options(): args = parser.parse_args() + if args.retryFile and args.url: + print("Cannot have url and retry flag!\n") + parser.print_help() + raise Exception() + + if not args.retryFile and not args.url: + print("Must pass either a url or a retry file!\n") + parser.print_help() + raise Exception() + return args @@ -218,11 +228,10 @@ def save_urls_from_playlist_to_file(filename, urls): if __name__ == "__main__": - args = get_command_line_options() - - if args.retryFile and args.url: - print("Cannot have url and retry flag!") - sys.exit(1) + try: + args = get_command_line_options() + except Exception as ex: + sys.exit() music_directory = args.output or os.path.join(os.path.expanduser("~"), "Music") |