11import  argparse 
2+ import  getpass 
23from  pathlib  import  Path 
34
4- from  .gttrl  import  Gttrl 
5+ from  .gttrl  import  Config ,  Gttrl 
56
6- __version__  =  "1.0 " 
7+ __version__  =  "1.1 " 
78
89
910def  main ():
1011    parser  =  argparse .ArgumentParser (
1112        description = "Glomatico's Toontown Rewritten Launcher" ,
12-         formatter_class = argparse .ArgumentDefaultsHelpFormatter ,
1313    )
1414    parser .add_argument (
1515        "-u" ,
@@ -24,13 +24,11 @@ def main():
2424    parser .add_argument (
2525        "-a" ,
2626        "--account-file" ,
27-         default = "./account.txt" ,
2827        help = "Account file location" ,
2928    )
3029    parser .add_argument (
31-         "-f " ,
30+         "-m " ,
3231        "--game-path" ,
33-         default = "./Toontown Rewritten" ,
3432        help = "Game path" ,
3533    )
3634    parser .add_argument (
@@ -59,7 +57,7 @@ def main():
5957        "-e" ,
6058        "--enable-log" ,
6159        action = "store_true" ,
62-         help = "Enable log " ,
60+         help = "Enable logging to the console " ,
6361    )
6462    parser .add_argument (
6563        "-v" ,
@@ -68,15 +66,18 @@ def main():
6866        version = f"%(prog)s { __version__ }  " ,
6967    )
7068    args  =  parser .parse_args ()
69+     config  =  Config ()
70+     config .create_if_not_exists ()
71+     config_file  =  config .read_config_file ()
7172    username  =  args .username 
7273    password  =  args .password 
73-     account_file  =  args .account_file 
74-     game_path  =  args .game_path 
74+     account_file  =  args .account_file   or   config_file [ "account_file" ] 
75+     game_path  =  args .game_path   or   config_file [ "game_path" ] 
7576    play_cookie  =  args .play_cookie 
7677    game_server  =  args .game_server 
77-     skip_update  =  args .skip_update 
78+     skip_update  =  args .skip_update   or   config_file [ "skip_update" ] 
7879    print_play_cookie  =  args .print_play_cookie 
79-     enable_log  =  args .enable_log 
80+     enable_log  =  args .enable_log   or   config_file [ "enable_log" ] 
8081    if  (username  and  not  password ) or  (password  and  not  username ):
8182        raise  Exception ("Username and password must be provided together" )
8283    elif  (play_cookie  and  not  game_server ) or  (game_server  and  not  play_cookie ):
@@ -86,9 +87,8 @@ def main():
8687            with  open (account_file , "r" ) as  file :
8788                username , password  =  file .read ().splitlines ()
8889        elif  not  username  and  not  play_cookie :
89-             raise  Exception (
90-                 "Account file does not exist and no others forms of authentication were provided" 
91-             )
90+             username  =  input ("Username: " )
91+             password  =  getpass .getpass ("Password: " )
9292    gttrl  =  Gttrl (username , password , game_path , enable_log )
9393    if  username :
9494        print ("Logging in..." )
0 commit comments