Skip to content

Commit fe500fd

Browse files
committed
more tmux convert
1 parent b9b62d4 commit fe500fd

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

tmuxp/cli.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,31 @@ def subcommand_convert(args):
195195
file_user = os.path.join(config_dir, configfile)
196196
file_cwd = os.path.join(cwd_dir, configfile)
197197
if os.path.exists(file_cwd) and os.path.isfile(file_cwd):
198-
print(file_cwd)
198+
fullfile = os.path.normpath(file_cwd)
199199
filename, ext = os.path.splitext(file_cwd)
200200
elif os.path.exists(file_user) and os.path.isfile(file_user):
201-
print(file_user)
201+
202+
fullfile = os.path.normpath(file_user)
202203
filename, ext = os.path.splitext(file_user)
203204
else:
204205
logger.error('%s not found.' % configfile)
205206
return
206207

207208
if 'json' in ext:
208-
if query_yes_no('convert to %s to yaml?' % (configfile)):
209-
print('converting')
209+
if query_yes_no('convert to <%s> to yaml?' % (fullfile)):
210+
configparser = kaptan.Kaptan()
211+
configparser.import_config(configfile)
212+
newfile = fullfile.replace(ext, '.yaml')
213+
if query_yes_no('write config to %s?' % (newfile)):
214+
print ('written new config to %s' % (newfile))
210215
elif 'yaml' in ext:
211-
if query_yes_no('convert to %s to json?' % (configfile)):
212-
print('converting')
216+
if query_yes_no('convert to <%s> to json?' % (fullfile)):
217+
configparser = kaptan.Kaptan()
218+
configparser.import_config(configfile)
219+
newfile = fullfile.replace(ext, '.json')
220+
if query_yes_no('write config to <%s>?' % (newfile)):
221+
print ('written new config to <%s>.' % (newfile))
222+
213223

214224

215225
def subcommand_attach_session(args):

0 commit comments

Comments
 (0)