23
23
24
24
config_dir = os .path .expanduser ('~/.tmuxp/' )
25
25
cwd_dir = os .getcwd () + '/'
26
-
26
+ tmuxinator_config_dir = os .path .expanduser ('~/.tmuxinator/' )
27
+ teamocil_config_dir = os .path .expanduser ('~/.teamocil/' )
27
28
28
29
def query_yes_no (question , default = "yes" ):
29
30
"""Ask a yes/no question via raw_input() and return their answer.
@@ -179,12 +180,58 @@ def subcommand_load(args):
179
180
180
181
181
182
def subcommand_import_teamocil (args ):
182
- print (args )
183
+ if args .list :
184
+ try :
185
+ configs_in_user = config .in_dir (teamocil_config_dir , extensions = 'yml' )
186
+ except OSError :
187
+ configs_in_user = []
188
+ configs_in_cwd = config .in_dir (config_dir = cwd_dir , extensions = 'yml' )
189
+
190
+ output = ''
191
+
192
+ if not os .path .exists (teamocil_config_dir ):
193
+ output += '# %s: \n \t Directory doesn\' t exist.\n ' % teamocil_config_dir
194
+ elif not configs_in_user :
195
+ output += '# %s: \n \t None found.\n ' % teamocil_config_dir
196
+ else :
197
+ output += '# %s: \n \t %s\n ' % (
198
+ config_dir , ', ' .join (configs_in_user )
199
+ )
200
+
201
+ if configs_in_cwd :
202
+ output += '# current directory:\n \t %s' % (
203
+ ', ' .join (configs_in_cwd )
204
+ )
205
+
206
+ print (output )
207
+
183
208
184
209
185
210
def subcommand_import_tmuxinator (args ):
186
- print (args )
211
+ if args .list :
212
+ try :
213
+ configs_in_user = config .in_dir (tmuxinator_config_dir , extensions = 'yml' )
214
+ except OSError :
215
+ configs_in_user = []
216
+ configs_in_cwd = config .in_dir (config_dir = cwd_dir , extensions = 'yml' )
217
+
218
+ output = ''
219
+
220
+ if not os .path .exists (tmuxinator_config_dir ):
221
+ output += '# %s: \n \t Directory doesn\' t exist.\n ' % tmuxinator_config_dir
222
+ elif not configs_in_user :
223
+ output += '# %s: \n \t None found.\n ' % tmuxinator_config_dir
224
+ else :
225
+ output += '# %s: \n \t %s\n ' % (
226
+ config_dir , ', ' .join (configs_in_user )
227
+ )
187
228
229
+ if configs_in_cwd :
230
+ output += '# current directory:\n \t %s' % (
231
+ ', ' .join (configs_in_cwd )
232
+ )
233
+
234
+ print (output )
188
235
189
236
def subcommand_convert (args ):
190
237
if args .config :
@@ -365,10 +412,16 @@ def cli_parser():
365
412
366
413
import_teamocil = importsubparser .add_parser ('teamocil' )
367
414
368
- import_teamocil .add_argument (
415
+ import_teamocilgroup = import_teamocil .add_mutually_exclusive_group (required = True )
416
+ import_teamocilgroup .add_argument (
417
+ '-l' , '--list' , dest = 'list' , action = 'store_true' ,
418
+ help = 'List yaml configs in ~/.teamocil and current working directory.'
419
+ )
420
+
421
+ import_teamocilgroup .add_argument (
369
422
dest = 'config' ,
370
423
type = str ,
371
- default = None ,
424
+ nargs = '?' ,
372
425
help = '''\
373
426
Checks current ~/.teamocil and current directory for yaml files.
374
427
'''
@@ -377,14 +430,21 @@ def cli_parser():
377
430
378
431
import_tmuxinator = importsubparser .add_parser ('tmuxinator' )
379
432
380
- import_tmuxinator .add_argument (
433
+ import_tmuxinatorgroup = import_tmuxinator .add_mutually_exclusive_group (required = True )
434
+ import_tmuxinatorgroup .add_argument (
435
+ '-l' , '--list' , dest = 'list' , action = 'store_true' ,
436
+ help = 'List yaml configs in ~/.tmuxinator and current working directory.'
437
+ )
438
+
439
+ import_tmuxinatorgroup .add_argument (
381
440
dest = 'config' ,
382
441
type = str ,
383
- default = None ,
442
+ nargs = '?' ,
384
443
help = '''\
385
444
Checks current ~/.tmuxinator and current directory for yaml files.
386
445
'''
387
446
)
447
+
388
448
import_tmuxinator .set_defaults (callback = subcommand_import_tmuxinator )
389
449
390
450
parser .add_argument ('--log-level' , dest = 'log_level' , default = 'INFO' ,
@@ -496,6 +556,20 @@ def config_complete(command, commands, ctext):
496
556
for c in config .in_dir (config_dir )]
497
557
commands += [c for c in configs if c .startswith (ctext_subargs )]
498
558
559
+ def teamocil_config_complete (command , commands , ctext ):
560
+ try :
561
+ configs_in_user = config .in_dir (teamocil_config_dir , extensions = 'yml' )
562
+ except OSError :
563
+ configs_in_user = []
564
+ configs_in_cwd = config .in_dir (config_dir = cwd_dir , extensions = 'yml' )
565
+
566
+ def tmuxinator_config_complete (command , commands , ctext ):
567
+ try :
568
+ configs_in_user = config .in_dir (tmuxinator_config_dir , extensions = 'yml' )
569
+ except OSError :
570
+ configs_in_user = []
571
+ configs_in_cwd = config .in_dir (config_dir = cwd_dir , extensions = 'yml' )
572
+
499
573
session_complete ('attach-session' , commands , ctext )
500
574
session_complete ('kill-session' , commands , ctext )
501
575
config_complete ('load' , commands , ctext )
0 commit comments