@@ -82,15 +82,18 @@ def __exit__(self, exc_type, exc_val, exc_tb):
8282
8383class Action :
8484
85- def __init__ (self , msg , ** kwargs ):
85+ def __init__ (self , msg , ok_msg = ' OK' , nl = False , ** kwargs ):
8686 self .msg = msg
87+ self .ok_msg = ok_msg
8788 self .msg_args = kwargs
89+ self .nl = nl
8890 self .errors = []
8991 self ._suppress_exception = False
90- self .ok_msg = ' OK'
9192
9293 def __enter__ (self ):
9394 action (self .msg , ** self .msg_args )
95+ if self .nl :
96+ secho ('' )
9497 return self
9598
9699 def __exit__ (self , exc_type , exc_val , exc_tb ):
@@ -134,7 +137,7 @@ def format_time(ts):
134137 diff = now - dt
135138 s = diff .total_seconds ()
136139 if s > (3600 * 49 ):
137- t = '{:.0f}d' .format (s / (3600 * 24 ))
140+ t = '{:.0f}d' .format (s / (3600 * 24 ))
138141 elif s > 3600 :
139142 t = '{:.0f}h' .format (s / 3600 )
140143 elif s > 70 :
@@ -208,7 +211,7 @@ def print_table(cols, rows, styles=None, titles=None, max_column_widths=None):
208211 for i , col in enumerate (cols ):
209212 click .secho (('{:' + str (colwidths [col ]) + '}' ).format (titles .get (col , col .title ().replace ('_' , ' ' ))),
210213 nl = False , fg = 'black' , bg = 'white' )
211- if i < len (cols )- 1 :
214+ if i < len (cols ) - 1 :
212215 click .secho ('│' , nl = False , fg = 'black' , bg = 'white' )
213216 click .echo ('' )
214217
@@ -256,12 +259,12 @@ def choice(prompt: str, options: list, default=None):
256259 value = label = option
257260 if value == default :
258261 promptdefault = i + 1
259- click .secho ('{}) {}' .format (i + 1 , label ), err = stderr )
262+ click .secho ('{}) {}' .format (i + 1 , label ), err = stderr )
260263 while True :
261264 selection = click .prompt ('Please select (1-{})' .format (len (options )),
262265 type = int , default = promptdefault , err = stderr )
263266 try :
264- result = options [int (selection )- 1 ]
267+ result = options [int (selection ) - 1 ]
265268 if isinstance (result , tuple ):
266269 value , label = result
267270 else :
@@ -275,6 +278,7 @@ class AliasedGroup(click.Group):
275278 """
276279 Click group which allows using abbreviated commands
277280 """
281+
278282 def get_command (self , ctx , cmd_name ):
279283 rv = click .Group .get_command (self , ctx , cmd_name )
280284 if rv is not None :
0 commit comments