88from datetime import datetime
99from db .database import db
1010
11- def add_user (username , traffic_gb , expiration_days , password = None , creation_date = None , unlimited_user = False , note = None ):
11+ def add_user (username , traffic_gb , expiration_days , password = None , unlimited_user = False , note = None , creation_date = None ):
1212 if not username or not traffic_gb or not expiration_days :
13- print (f"Usage: { sys .argv [0 ]} <username> <traffic_limit_GB> <expiration_days> [password] [creation_date] [ unlimited_user (true/false)] [note]" )
13+ print (f"Usage: { sys .argv [0 ]} <username> <traffic_limit_GB> <expiration_days> [password] [unlimited_user (true/false)] [note] [creation_date ]" )
1414 return 1
1515
1616 if db is None :
@@ -84,17 +84,17 @@ def add_user(username, traffic_gb, expiration_days, password=None, creation_date
8484
8585if __name__ == "__main__" :
8686 if len (sys .argv ) < 4 or len (sys .argv ) > 8 :
87- print (f"Usage: { sys .argv [0 ]} <username> <traffic_limit_GB> <expiration_days> [password] [creation_date] [ unlimited_user (true/false)] [note]" )
87+ print (f"Usage: { sys .argv [0 ]} <username> <traffic_limit_GB> <expiration_days> [password] [unlimited_user (true/false)] [note] [creation_date ]" )
8888 sys .exit (1 )
8989
9090 username = sys .argv [1 ]
9191 traffic_gb = sys .argv [2 ]
9292 expiration_days = sys .argv [3 ]
93- password = sys .argv [4 ] if len (sys .argv ) > 4 else None
94- creation_date = sys .argv [5 ] if len (sys .argv ) > 5 else None
95- unlimited_user_str = sys .argv [6 ] if len (sys .argv ) > 6 else "false"
93+ password = sys .argv [4 ] if len (sys .argv ) > 4 and sys .argv [4 ] else None
94+ unlimited_user_str = sys .argv [5 ] if len (sys .argv ) > 5 else "false"
9695 unlimited_user = unlimited_user_str .lower () == 'true'
97- note = sys .argv [7 ] if len (sys .argv ) > 7 else None
96+ note = sys .argv [6 ] if len (sys .argv ) > 6 and sys .argv [6 ] else None
97+ creation_date = sys .argv [7 ] if len (sys .argv ) > 7 and sys .argv [7 ] else None
9898
99- exit_code = add_user (username , traffic_gb , expiration_days , password , creation_date , unlimited_user , note )
99+ exit_code = add_user (username , traffic_gb , expiration_days , password , unlimited_user , note , creation_date )
100100 sys .exit (exit_code )
0 commit comments