@@ -262,7 +262,7 @@ def load_workspace(config_file, args):
262262 builder .build ()
263263
264264 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?' ):
266266 tmux_env = os .environ .pop ('TMUX' )
267267 builder .session .switch_client ()
268268
@@ -273,7 +273,7 @@ def load_workspace(config_file, args):
273273
274274 builder .session .attach_session ()
275275 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 ):
277277 if 'TMUX' in os .environ :
278278 builder .session .switch_client ()
279279
@@ -340,7 +340,7 @@ def command_freeze(args):
340340 '---------------------------------------------------------------' )
341341 print (
342342 'Configuration import does its best to convert teamocil files.\n ' )
343- if prompt_yes_no (
343+ if args . answer_yes or prompt_yes_no (
344344 'The new config *WILL* require adjusting afterwards. Save config?'
345345 ):
346346 dest = None
@@ -354,7 +354,7 @@ def command_freeze(args):
354354 dest = dest_prompt
355355
356356 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 ):
358358 buf = open (dest , 'w' )
359359 buf .write (newconfig )
360360 buf .close ()
@@ -474,7 +474,7 @@ def command_import_teamocil(args):
474474 '---------------------------------------------------------------' )
475475 print (
476476 'Configuration import does its best to convert teamocil files.\n ' )
477- if prompt_yes_no (
477+ if args . answer_yes or prompt_yes_no (
478478 'The new config *WILL* require adjusting afterwards. Save config?'
479479 ):
480480 dest = None
@@ -488,7 +488,7 @@ def command_import_teamocil(args):
488488 dest = dest_prompt
489489
490490 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 ):
492492 buf = open (dest , 'w' )
493493 buf .write (newconfig )
494494 buf .close ()
@@ -561,7 +561,7 @@ def command_import_tmuxinator(args):
561561 '---------------------------------------------------------------' )
562562 print (
563563 'Configuration import does its best to convert tmuxinator files.\n ' )
564- if prompt_yes_no (
564+ if args . answer_yes or prompt_yes_no (
565565 'The new config *WILL* require adjusting afterwards. Save config?'
566566 ):
567567 dest = None
@@ -575,7 +575,7 @@ def command_import_tmuxinator(args):
575575 dest = dest_prompt
576576
577577 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 ):
579579 buf = open (dest , 'w' )
580580 buf .write (newconfig )
581581 buf .close ()
@@ -611,26 +611,26 @@ def command_convert(args):
611611 return
612612
613613 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 )):
615615 configparser = kaptan .Kaptan ()
616616 configparser .import_config (configfile )
617617 newfile = fullfile .replace (ext , '.yaml' )
618618 newconfig = configparser .export (
619619 'yaml' , indent = 2 , default_flow_style = False
620620 )
621- if prompt_yes_no ('write config to %s?' % (newfile )):
621+ if args . answer_yes or prompt_yes_no ('write config to %s?' % (newfile )):
622622 buf = open (newfile , 'w' )
623623 buf .write (newconfig )
624624 buf .close ()
625625 print ('written new config to %s' % (newfile ))
626626 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 )):
628628 configparser = kaptan .Kaptan ()
629629 configparser .import_config (configfile )
630630 newfile = fullfile .replace (ext , '.json' )
631631 newconfig = configparser .export ('json' , indent = 2 )
632632 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 )):
634634 buf = open (newfile , 'w' )
635635 buf .write (newconfig )
636636 buf .close ()
@@ -719,6 +719,14 @@ def get_parser():
719719 metavar = 'socket-path'
720720 )
721721
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+
722730 parser = argparse .ArgumentParser (
723731 description = 'Launch tmux workspace. '
724732 'Help documentation: <http://tmuxp.rtfd.org>.' ,
0 commit comments