Fixed for flags

This commit is contained in:
Dimitris Zlatanidis 2022-12-21 22:34:55 +02:00
parent 777694d063
commit 803cefe223

View file

@ -45,7 +45,7 @@ class Argparse:
# Check for correct flag
for opt in self.args:
if opt.startswith('--'):
if opt not in self.options and opt != '--help':
if opt not in self.options and opt not in ['--help', '--version']:
raise SystemExit(f"\nError: flag '{opt}' does not exist.\n")
# Remove flags from args
@ -74,6 +74,9 @@ class Argparse:
self.usage.help(1)
def upgrade(self):
if [f for f in self.flags if f not in self.options[:-2]]:
self.usage.help(1)
if len(self.args) == 1:
self.check.database()
@ -99,7 +102,10 @@ class Argparse:
self.usage.help(1)
def build(self):
if len(self.args) >= 2 and '--reinstall' not in self.flags:
if [f for f in self.flags if f not in self.options[:-3]]:
self.usage.help(1)
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
self.check.database()
@ -112,6 +118,9 @@ class Argparse:
self.usage.help(1)
def install(self):
if [f for f in self.flags if f not in self.options[:-1]]:
self.usage.help(1)
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
@ -154,6 +163,9 @@ class Argparse:
self.usage.help(1)
def view(self):
if [f for f in self.flags if f not in self.options[5]]:
self.usage.help(1)
if len(self.args) >= 2:
packages = list(set(self.args[1:]))