@@ -262,7 +262,7 @@ def load_workspace(config_file, args):
262
262
builder .build ()
263
263
264
264
if 'TMUX' in os .environ :
265
- if prompt_yes_no ('Already inside TMUX, switch to session?' ):
265
+ if args . answer_yes or prompt_yes_no ('Already inside TMUX, switch to session?' ):
266
266
tmux_env = os .environ .pop ('TMUX' )
267
267
builder .session .switch_client ()
268
268
@@ -273,7 +273,7 @@ def load_workspace(config_file, args):
273
273
274
274
builder .session .attach_session ()
275
275
except exc .TmuxSessionExists as e :
276
- if prompt_yes_no ('%s Attach?' % e ):
276
+ if args . answer_yes or prompt_yes_no ('%s Attach?' % e ):
277
277
if 'TMUX' in os .environ :
278
278
builder .session .switch_client ()
279
279
@@ -340,7 +340,7 @@ def command_freeze(args):
340
340
'---------------------------------------------------------------' )
341
341
print (
342
342
'Configuration import does its best to convert teamocil files.\n ' )
343
- if prompt_yes_no (
343
+ if args . answer_yes or prompt_yes_no (
344
344
'The new config *WILL* require adjusting afterwards. Save config?'
345
345
):
346
346
dest = None
@@ -354,7 +354,7 @@ def command_freeze(args):
354
354
dest = dest_prompt
355
355
356
356
dest = os .path .abspath (os .path .relpath (os .path .expanduser (dest )))
357
- if prompt_yes_no ('Write to %s?' % dest ):
357
+ if args . answer_yes or prompt_yes_no ('Write to %s?' % dest ):
358
358
buf = open (dest , 'w' )
359
359
buf .write (newconfig )
360
360
buf .close ()
@@ -474,7 +474,7 @@ def command_import_teamocil(args):
474
474
'---------------------------------------------------------------' )
475
475
print (
476
476
'Configuration import does its best to convert teamocil files.\n ' )
477
- if prompt_yes_no (
477
+ if args . answer_yes or prompt_yes_no (
478
478
'The new config *WILL* require adjusting afterwards. Save config?'
479
479
):
480
480
dest = None
@@ -488,7 +488,7 @@ def command_import_teamocil(args):
488
488
dest = dest_prompt
489
489
490
490
dest = os .path .abspath (os .path .relpath (os .path .expanduser (dest )))
491
- if prompt_yes_no ('Write to %s?' % dest ):
491
+ if args . answer_yes or prompt_yes_no ('Write to %s?' % dest ):
492
492
buf = open (dest , 'w' )
493
493
buf .write (newconfig )
494
494
buf .close ()
@@ -561,7 +561,7 @@ def command_import_tmuxinator(args):
561
561
'---------------------------------------------------------------' )
562
562
print (
563
563
'Configuration import does its best to convert tmuxinator files.\n ' )
564
- if prompt_yes_no (
564
+ if args . answer_yes or prompt_yes_no (
565
565
'The new config *WILL* require adjusting afterwards. Save config?'
566
566
):
567
567
dest = None
@@ -575,7 +575,7 @@ def command_import_tmuxinator(args):
575
575
dest = dest_prompt
576
576
577
577
dest = os .path .abspath (os .path .relpath (os .path .expanduser (dest )))
578
- if prompt_yes_no ('Write to %s?' % dest ):
578
+ if args . answer_yes or prompt_yes_no ('Write to %s?' % dest ):
579
579
buf = open (dest , 'w' )
580
580
buf .write (newconfig )
581
581
buf .close ()
@@ -611,26 +611,26 @@ def command_convert(args):
611
611
return
612
612
613
613
if 'json' in ext :
614
- if prompt_yes_no ('convert to <%s> to yaml?' % (fullfile )):
614
+ if args . answer_yes or prompt_yes_no ('convert to <%s> to yaml?' % (fullfile )):
615
615
configparser = kaptan .Kaptan ()
616
616
configparser .import_config (configfile )
617
617
newfile = fullfile .replace (ext , '.yaml' )
618
618
newconfig = configparser .export (
619
619
'yaml' , indent = 2 , default_flow_style = False
620
620
)
621
- if prompt_yes_no ('write config to %s?' % (newfile )):
621
+ if args . answer_yes or prompt_yes_no ('write config to %s?' % (newfile )):
622
622
buf = open (newfile , 'w' )
623
623
buf .write (newconfig )
624
624
buf .close ()
625
625
print ('written new config to %s' % (newfile ))
626
626
elif 'yaml' in ext :
627
- if prompt_yes_no ('convert to <%s> to json?' % (fullfile )):
627
+ if args . answer_yes or prompt_yes_no ('convert to <%s> to json?' % (fullfile )):
628
628
configparser = kaptan .Kaptan ()
629
629
configparser .import_config (configfile )
630
630
newfile = fullfile .replace (ext , '.json' )
631
631
newconfig = configparser .export ('json' , indent = 2 )
632
632
print (newconfig )
633
- if prompt_yes_no ('write config to <%s>?' % (newfile )):
633
+ if args . answer_yes or prompt_yes_no ('write config to <%s>?' % (newfile )):
634
634
buf = open (newfile , 'w' )
635
635
buf .write (newconfig )
636
636
buf .close ()
@@ -719,6 +719,14 @@ def get_parser():
719
719
metavar = 'socket-path'
720
720
)
721
721
722
+ server_parser .add_argument (
723
+ '-y' ,
724
+ dest = 'answer_yes' ,
725
+ default = None ,
726
+ help = 'Always answer yes.' ,
727
+ action = 'store_true'
728
+ )
729
+
722
730
parser = argparse .ArgumentParser (
723
731
description = 'Launch tmux workspace. '
724
732
'Help documentation: <http://tmuxp.rtfd.org>.' ,
0 commit comments