Fixed for flag --help

This commit is contained in:
Dimitris Zlatanidis 2022-12-21 21:34:17 +02:00
parent 42fb6bf7c5
commit 22ead694de

View file

@ -42,15 +42,17 @@ class Argparse:
'--skip-installed',
'--dependees']
# Check for correct flag
for opt in self.args:
if opt.startswith('--'):
if opt not in self.options:
if opt not in self.options and opt != '--help':
raise SystemExit(f"\nError: flag '{opt}' does not exist.\n")
for option in self.options:
if option in self.args:
self.args.remove(option)
self.flags.append(option)
# Remove flags from args
for opt in self.options:
if opt in self.args:
self.args.remove(opt)
self.flags.append(opt)
def help(self):
if len(self.args) == 1 and not self.flags: