@@ -187,15 +187,29 @@ def subcommand_convert(args):
187187 else :
188188 print ('No tmuxp configs found in current directory.' )
189189
190- for configfile in args .configs :
191- file_user = os .path .join (config_dir , configfile )
192- file_cwd = os .path .join (cwd_dir , configfile )
193- if os .path .exists (file_cwd ) and os .path .isfile (file_cwd ):
194- print (file_cwd )
195- elif os .path .exists (file_user ) and os .path .isfile (file_user ):
196- print (file_user )
197- else :
198- logger .error ('%s not found.' % configfile )
190+ try :
191+ configfile = args .configs [0 ]
192+ except Exception :
193+ print ('Please enter a config' )
194+
195+ file_user = os .path .join (config_dir , configfile )
196+ file_cwd = os .path .join (cwd_dir , configfile )
197+ if os .path .exists (file_cwd ) and os .path .isfile (file_cwd ):
198+ print (file_cwd )
199+ filename , ext = os .path .splitext (file_cwd )
200+ elif os .path .exists (file_user ) and os .path .isfile (file_user ):
201+ print (file_user )
202+ filename , ext = os .path .splitext (file_user )
203+ else :
204+ logger .error ('%s not found.' % configfile )
205+ return
206+
207+ if 'json' in ext :
208+ if query_yes_no ('convert to %s to yaml?' % (configfile )):
209+ print ('converting' )
210+ elif 'yaml' in ext :
211+ if query_yes_no ('convert to %s to json?' % (configfile )):
212+ print ('converting' )
199213
200214
201215def subcommand_attach_session (args ):
@@ -345,6 +359,8 @@ def main():
345359
346360 if args .callback is subcommand_load :
347361 subcommand_load (args )
362+ elif args .callback is subcommand_convert :
363+ subcommand_convert (args )
348364 elif args .callback is subcommand_attach_session :
349365 subcommand_attach_session (args )
350366 elif args .callback is subcommand_kill_session :
0 commit comments