@@ -198,7 +198,7 @@ def setup_logger(logger=None, level='INFO'):
198198 channel = logging .StreamHandler ()
199199 channel .setFormatter (log .DebugLogFormatter ())
200200
201- #channel.setFormatter(log.LogFormatter())
201+ # channel.setFormatter(log.LogFormatter())
202202 logger .setLevel (level )
203203 logger .addHandler (channel )
204204
@@ -231,7 +231,8 @@ def load_workspace(config_file, args):
231231
232232 t = Server (
233233 socket_name = args .socket_name ,
234- socket_path = args .socket_path
234+ socket_path = args .socket_path ,
235+ colors = args .colors
235236 )
236237
237238 try :
@@ -288,14 +289,19 @@ def load_workspace(config_file, args):
288289 sys .exit ()
289290
290291
292+ def get_server_from_args (args ):
293+ """ Return a :class:`Server` object from the argparse response.
294+
295+ tmuxp allows flags such as -L, -S, -2 and -8.
296+ may delete. sec
297+
298+ """
299+ pass
300+
301+
291302def command_freeze (args ):
292303 """ Import teamocil config to tmuxp format. """
293304
294- t = Server (
295- socket_name = args .socket_name ,
296- socket_path = args .socket_path
297- )
298-
299305 logger .error (args )
300306 session = t .findWhere ({
301307 'session_name' : args .session_name
@@ -306,7 +312,7 @@ def command_freeze(args):
306312 newconfig = config .inline (sconf )
307313 configparser .import_config (newconfig )
308314 config_format = prompt_choices ('Convert to' , choices = [
309- 'yaml' , 'json' ], default = 'yaml' )
315+ 'yaml' , 'json' ], default = 'yaml' )
310316
311317 if config_format == 'yaml' :
312318 newconfig = configparser .export (
@@ -350,8 +356,6 @@ def command_freeze(args):
350356 sys .exit ()
351357
352358
353-
354-
355359def command_load (args ):
356360 """ Load a session from a tmuxp session file. """
357361 if args .list :
@@ -613,17 +617,15 @@ def command_convert(args):
613617 print ('written new config to <%s>.' % (newfile ))
614618
615619
616-
617-
618-
619620def command_attach_session (args ):
620621 """ Command to attach / switch client to a tmux session."""
621622 commands = []
622623 ctext = args .session_name
623624
624625 t = Server (
625- socket_name = args .socket_name or None ,
626- socket_path = args .socket_path or None
626+ socket_name = args .socket_name ,
627+ socket_path = args .socket_path ,
628+ colors = args .colors
627629 )
628630 try :
629631 session = next ((s for s in t .sessions if s .get (
@@ -805,6 +807,30 @@ def get_parser():
805807 help = 'socket path of tmux server. Same as tmux.' ,
806808 metavar = 'socket-path' )
807809
810+ colorsgroup = parser .add_mutually_exclusive_group (
811+ required = True
812+ )
813+
814+ colorsgroup .add_argument (
815+ '-2' ,
816+ dest = 'colors' ,
817+ # action='store_true',
818+ action = 'store_const' ,
819+ const = 256 ,
820+ help = 'Force tmux to assume the terminal supports 256 colours.' ,
821+ )
822+
823+ colorsgroup .add_argument (
824+ '-8' ,
825+ dest = 'colors' ,
826+ # action='store_true',
827+ action = 'store_const' ,
828+ const = 88 ,
829+ help = 'Like -2, but indicates that the terminal supports 88 colours.' ,
830+ )
831+
832+ parser .set_defaults (colors = None )
833+
808834 # http://stackoverflow.com/questions/8521612/argparse-optional-subparser
809835 parser .add_argument (
810836 '-v' , '--version' , action = 'version' ,
@@ -832,6 +858,12 @@ def main():
832858
833859 util .oh_my_zsh_auto_title ()
834860
861+ t = Server (
862+ socket_name = args .socket_name ,
863+ socket_path = args .socket_path ,
864+ colors = args .colors
865+ )
866+
835867 if args .callback is command_load :
836868 command_load (args )
837869 elif args .callback is command_convert :
0 commit comments