From 930b8478d569f74f6153ac522c9bdefa450ecea7 Mon Sep 17 00:00:00 2001 From: Jackson Taylor Date: Mon, 8 Aug 2022 07:43:59 -0400 Subject: 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. --- jamos | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/jamos b/jamos index c068b5c..e947e3d 100755 --- a/jamos +++ b/jamos @@ -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") -- cgit v1.2.3