26
26
tmuxinator_config_dir = os .path .expanduser ('~/.tmuxinator/' )
27
27
teamocil_config_dir = os .path .expanduser ('~/.teamocil/' )
28
28
29
+
29
30
def query_yes_no (question , default = "yes" ):
30
31
"""Ask a yes/no question via raw_input() and return their answer.
31
32
@@ -182,10 +183,12 @@ def subcommand_load(args):
182
183
def subcommand_import_teamocil (args ):
183
184
if args .list :
184
185
try :
185
- configs_in_user = config .in_dir (teamocil_config_dir , extensions = 'yml' )
186
+ configs_in_user = config .in_dir (
187
+ teamocil_config_dir , extensions = 'yml' )
186
188
except OSError :
187
189
configs_in_user = []
188
- configs_in_cwd = config .in_dir (config_dir = cwd_dir , extensions = 'yml' )
190
+ configs_in_cwd = config .in_dir (
191
+ config_dir = cwd_dir , extensions = 'yml' )
189
192
190
193
output = ''
191
194
@@ -205,15 +208,30 @@ def subcommand_import_teamocil(args):
205
208
206
209
print (output )
207
210
211
+ if args .config :
212
+ configfile = os .path .relpath (args .config )
213
+ configparser = kaptan .Kaptan (handler = 'yaml' )
214
+ configparser .import_config (configfile )
215
+
216
+ newconfig = config .import_teamocil (configparser .get ())
217
+
218
+ newconfig = configparser .import_config (newconfig )
219
+ newconfig = configparser .export (
220
+ 'yaml' , indent = 2 , default_flow_style = False
221
+ )
222
+
223
+ print (newconfig )
208
224
209
225
210
226
def subcommand_import_tmuxinator (args ):
211
227
if args .list :
212
228
try :
213
- configs_in_user = config .in_dir (tmuxinator_config_dir , extensions = 'yml' )
229
+ configs_in_user = config .in_dir (
230
+ tmuxinator_config_dir , extensions = 'yml' )
214
231
except OSError :
215
232
configs_in_user = []
216
- configs_in_cwd = config .in_dir (config_dir = cwd_dir , extensions = 'yml' )
233
+ configs_in_cwd = config .in_dir (
234
+ config_dir = cwd_dir , extensions = 'yml' )
217
235
218
236
output = ''
219
237
@@ -233,6 +251,21 @@ def subcommand_import_tmuxinator(args):
233
251
234
252
print (output )
235
253
254
+ if args .config :
255
+ configfile = os .path .relpath (args .config )
256
+ configparser = kaptan .Kaptan (handler = 'yaml' )
257
+ configparser .import_config (configfile )
258
+
259
+ newconfig = config .import_tmuxinator (configparser .get ())
260
+
261
+ newconfig = configparser .import_config (newconfig )
262
+ newconfig = configparser .export (
263
+ 'yaml' , indent = 2 , default_flow_style = False
264
+ )
265
+
266
+ print (newconfig )
267
+
268
+
236
269
def subcommand_convert (args ):
237
270
if args .config :
238
271
if '.' in args .config :
@@ -296,7 +329,8 @@ def subcommand_attach_session(args):
296
329
socket_path = args .socket_path or None
297
330
)
298
331
try :
299
- session = next ((s for s in t .sessions if s .get ('session_name' ) == ctext ), None )
332
+ session = next ((s for s in t .sessions if s .get (
333
+ 'session_name' ) == ctext ), None )
300
334
if not session :
301
335
raise Exception ('Session not found.' )
302
336
except Exception as e :
@@ -322,7 +356,8 @@ def subcommand_kill_session(args):
322
356
)
323
357
324
358
try :
325
- session = next ((s for s in t .sessions if s .get ('session_name' ) == ctext ), None )
359
+ session = next ((s for s in t .sessions if s .get (
360
+ 'session_name' ) == ctext ), None )
326
361
if not session :
327
362
raise Exception ('Session not found.' )
328
363
except Exception as e :
@@ -412,7 +447,8 @@ def cli_parser():
412
447
413
448
import_teamocil = importsubparser .add_parser ('teamocil' )
414
449
415
- import_teamocilgroup = import_teamocil .add_mutually_exclusive_group (required = True )
450
+ import_teamocilgroup = import_teamocil .add_mutually_exclusive_group (
451
+ required = True )
416
452
import_teamocilgroup .add_argument (
417
453
'-l' , '--list' , dest = 'list' , action = 'store_true' ,
418
454
help = 'List yaml configs in ~/.teamocil and current working directory.'
@@ -430,7 +466,8 @@ def cli_parser():
430
466
431
467
import_tmuxinator = importsubparser .add_parser ('tmuxinator' )
432
468
433
- import_tmuxinatorgroup = import_tmuxinator .add_mutually_exclusive_group (required = True )
469
+ import_tmuxinatorgroup = import_tmuxinator .add_mutually_exclusive_group (
470
+ required = True )
434
471
import_tmuxinatorgroup .add_argument (
435
472
'-l' , '--list' , dest = 'list' , action = 'store_true' ,
436
473
help = 'List yaml configs in ~/.tmuxinator and current working directory.'
@@ -558,14 +595,16 @@ def config_complete(command, commands, ctext):
558
595
559
596
def teamocil_config_complete (command , commands , ctext ):
560
597
try :
561
- configs_in_user = config .in_dir (teamocil_config_dir , extensions = 'yml' )
598
+ configs_in_user = config .in_dir (
599
+ teamocil_config_dir , extensions = 'yml' )
562
600
except OSError :
563
601
configs_in_user = []
564
602
configs_in_cwd = config .in_dir (config_dir = cwd_dir , extensions = 'yml' )
565
603
566
604
def tmuxinator_config_complete (command , commands , ctext ):
567
605
try :
568
- configs_in_user = config .in_dir (tmuxinator_config_dir , extensions = 'yml' )
606
+ configs_in_user = config .in_dir (
607
+ tmuxinator_config_dir , extensions = 'yml' )
569
608
except OSError :
570
609
configs_in_user = []
571
610
configs_in_cwd = config .in_dir (config_dir = cwd_dir , extensions = 'yml' )
0 commit comments