@@ -29,7 +29,7 @@ def ensure_str(s: ty.Any) -> str:
29
29
30
30
def trim (string : str , length : int = 70 ) -> str :
31
31
"""Trim a string to the given length."""
32
- return (string [:length - 1 ] + '...' ) if len (string ) > length else string
32
+ return (string [: length - 1 ] + '...' ) if len (string ) > length else string
33
33
34
34
35
35
def git_config (value : str ) -> str :
@@ -86,7 +86,8 @@ def _tabulate(
86
86
elif fmt == 'csv' :
87
87
result = io .StringIO ()
88
88
writer = csv .writer (
89
- result , quoting = csv .QUOTE_ALL , lineterminator = os .linesep )
89
+ result , quoting = csv .QUOTE_ALL , lineterminator = os .linesep
90
+ )
90
91
writer .writerow ([ensure_str (h ) for h in headers ])
91
92
for item in output :
92
93
writer .writerow ([ensure_str (i ) for i in item ])
@@ -165,19 +166,32 @@ def echo(
165
166
166
167
167
168
def pagination_options (
168
- sort_fields : ty .Tuple [str , ...], default_sort : str ,
169
+ sort_fields : ty .Tuple [str , ...],
170
+ default_sort : str ,
169
171
) -> ty .Callable :
170
172
"""Shared pagination options."""
171
173
172
174
def _pagination_options (f ):
173
- f = click .option ('--limit' , metavar = 'LIMIT' , type = click .INT ,
174
- help = 'Maximum number of items to show.' )(f )
175
- f = click .option ('--page' , metavar = 'PAGE' , type = click .INT ,
176
- help = 'Page to retrieve items from. This is '
177
- 'influenced by the size of LIMIT.' )(f )
178
- f = click .option ('--sort' , metavar = 'FIELD' , default = default_sort ,
179
- type = click .Choice (sort_fields ),
180
- help = 'Sort output on given field.' )(f )
175
+ f = click .option (
176
+ '--limit' ,
177
+ metavar = 'LIMIT' ,
178
+ type = click .INT ,
179
+ help = 'Maximum number of items to show.' ,
180
+ )(f )
181
+ f = click .option (
182
+ '--page' ,
183
+ metavar = 'PAGE' ,
184
+ type = click .INT ,
185
+ help = 'Page to retrieve items from. This is '
186
+ 'influenced by the size of LIMIT.' ,
187
+ )(f )
188
+ f = click .option (
189
+ '--sort' ,
190
+ metavar = 'FIELD' ,
191
+ default = default_sort ,
192
+ type = click .Choice (sort_fields ),
193
+ help = 'Sort output on given field.' ,
194
+ )(f )
181
195
182
196
return f
183
197
@@ -191,16 +205,29 @@ def format_options(
191
205
"""Shared output format options."""
192
206
193
207
def _format_options (f ):
194
- f = click .option ('--format' , '-f' , 'fmt' , default = None ,
195
- type = click .Choice (['simple' , 'table' , 'csv' ]),
196
- help = "Output format. Defaults to the value of "
197
- "'git config pw.format' else 'table'." )(f )
208
+ f = click .option (
209
+ '--format' ,
210
+ '-f' ,
211
+ 'fmt' ,
212
+ default = None ,
213
+ type = click .Choice (['simple' , 'table' , 'csv' ]),
214
+ help = (
215
+ "Output format. Defaults to the value of "
216
+ "'git config pw.format' else 'table'."
217
+ ),
218
+ )(f )
198
219
199
220
if headers :
200
- f = click .option ('--column' , '-c' , 'headers' , metavar = 'COLUMN' ,
201
- multiple = True , default = headers ,
202
- type = click .Choice (headers ),
203
- help = 'Columns to be included in output.' )(f )
221
+ f = click .option (
222
+ '--column' ,
223
+ '-c' ,
224
+ 'headers' ,
225
+ metavar = 'COLUMN' ,
226
+ multiple = True ,
227
+ default = headers ,
228
+ type = click .Choice (headers ),
229
+ help = 'Columns to be included in output.' ,
230
+ )(f )
204
231
return f
205
232
206
233
if original_function :
0 commit comments