Browse Source

Change invalid argument error handling

notcammy 7 years ago
parent
commit
ec3ff37787
1 changed files with 10 additions and 20 deletions
  1. 10 20
      pyinstalive/initialize.py

+ 10 - 20
pyinstalive/initialize.py

@@ -287,26 +287,16 @@ def run():
 	parser.add_argument('--noreplayx', help=argparse.SUPPRESS, metavar='IGNORE')
 
 	# Erase line that tells the user the error has to do with ambiguous arguments
-	try:
-		args = parser.parse_args()
-	except SystemExit as e:
-		args_raw = sys.argv[1:]
-		if "-h" not in args_raw and "--help" not in args_raw:
-			CURSOR_UP_ONE = '\x1b[1A'
-			ERASE_LINE = '\x1b[2K'
-			log(CURSOR_UP_ONE * 2 + ERASE_LINE + CURSOR_UP_ONE + "[E] Invalid argument(s) were provided in command: " + ' ' * 50, "RED")
-			log("    pyinstalive " + ' '.join(args_raw)  + ' ' * 50, "YELLOW")
-			log(' ' * 50, "GREEN")
-			log("[I] \033[94mpyinstalive -h\033[92m can be used to display command help."  + ' ' * 50, "GREEN")
-			sys.exit(1)
-		else:
-			sys.exit(0)
-
-	if (args.username == None 
-		and args.password == None 
-		and args.record == None 
-		and args.info == False 
-		and args.config == False) or (args.info != False):
+	args, unknown = parser.parse_known_args()
+	if unknown:
+		log("[E] The following invalid argument(s) were provided: ", "RED") 
+		log('', "GREEN") 
+		log(' '.join(unknown), "YELLOW") 
+		log('', "GREEN") 
+		log("[I] \033[94mpyinstalive -h\033[92m can be used to display command help.", "GREEN")
+		exit(1)
+
+	if (len(vars(args)) == 12) or (args.info):
 		show_info(config)
 		sys.exit(0)