Updated checks for script arguments
This commit is contained in:
parent
35391e6173
commit
f0a02ec2d0
|
@ -15,7 +15,8 @@ def run(*args):
|
||||||
raise ValueError("Invalid number of arguments passed")
|
raise ValueError("Invalid number of arguments passed")
|
||||||
|
|
||||||
if args[0] in ("manual", "man") :
|
if args[0] in ("manual", "man") :
|
||||||
if not args:
|
|
||||||
|
if len(args) != 2 or not args[1].isdigit() or int(args[1]) < 1:
|
||||||
raise ValueError("Invalid number of arguments passed")
|
raise ValueError("Invalid number of arguments passed")
|
||||||
|
|
||||||
print("id\troll_no\tname\tbranch\tphone_number\tcpi\tdegree\tbatch")
|
print("id\troll_no\tname\tbranch\tphone_number\tcpi\tdegree\tbatch")
|
||||||
|
@ -40,7 +41,7 @@ def run(*args):
|
||||||
student.save()
|
student.save()
|
||||||
|
|
||||||
elif args[0] in ("auto", "automatic"):
|
elif args[0] in ("auto", "automatic"):
|
||||||
if not args:
|
if len(args) != 2 or not args[1].isdigit() or int(args[1]) < 1:
|
||||||
raise ValueError("Invalid number of arguments passed")
|
raise ValueError("Invalid number of arguments passed")
|
||||||
|
|
||||||
for i in range(1, int(args[1])+1):
|
for i in range(1, int(args[1])+1):
|
||||||
|
@ -61,7 +62,7 @@ def run(*args):
|
||||||
|
|
||||||
elif args[0] in ("del", "delete"):
|
elif args[0] in ("del", "delete"):
|
||||||
# delete students with name starting with Student
|
# delete students with name starting with Student
|
||||||
s = Student.objects.filter(name__startswith="Student")
|
s = Student.objects.filter(name__startswith="Stundent")
|
||||||
s.delete()
|
s.delete()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue