@@ -35,6 +35,7 @@ def cli(caller_file):
3535 argp .add_argument ('--exclude-langs' , '--exclude-lang' , type = str , help = 'Languages to exclude (e.g. "en,es")' )
3636 argp .add_argument ('--exclude-keys' , '--ignore-keys' , type = str , help = 'Keys to ignore (e.g. "appName,author")' )
3737 argp .add_argument ('-i' , '--init' , action = 'store_true' , help = f'Create { cli .name } .config.json file to store defaults' )
38+ argp .add_argument ('-f' , '--force' , action = 'store_true' , help = 'Force overwrite existing config file when using --init' )
3839 argp .add_argument ('-W' , '--no-wizard' , '--skip-wizard' ,
3940 action = 'store_true' , default = None , help = 'Skip interactive prompts during start-up' )
4041 argp .add_argument ('-h' , '--help' , action = 'help' , help = "Show help screen" )
@@ -49,12 +50,19 @@ def cli(caller_file):
4950 cli .config .locales_dir = getattr (cli .config , 'locales_dir' , '_locales' )
5051 if cli .config .exclude_langs :
5152 cli .config .target_locales = [lang for lang in cli .config .target_locales if lang not in cli .config .exclude_langs ]
53+ cli .config .force = getattr (cli .config , 'force' , False )
5254 cli .config .no_wizard = getattr (cli .config , 'no_wizard' , False )
5355
5456 return cli
5557
5658def config_file (cli ):
57- if os .path .exists (cli .config_path ) : return print (f'Config already exists at { cli .config_path } ' )
59+ if os .path .exists (cli .config_path ):
60+ if cli .config .force :
61+ print (f'Overwriting existing config at { cli .config_path } ...' )
62+ else :
63+ print (f'Config already exists at { cli .config_path } .Skipping --init.' )
64+ print ('\n TIP: Pass --force to overwrite.' )
65+ return
5866 cli .config_filename = '.translate-msgs.config.json'
5967 cli .config_path = os .path .join (cli .project_root , cli .config_filename )
6068 try :
0 commit comments