FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
GitCode-API/gitcode_api/cli.py at main · Trenza1ore/GitCode-API · GitHub
Trenza1ore
/
GitCode-API
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
7
Code
Issues
0
Pull requests
0
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
GitCode-API
/
gitcode_api
/
cli.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
490 lines (413 loc) · 18.3 KB
Breadcrumbs
GitCode-API
/
gitcode_api
/
cli.py
Copy path
File metadata and controls
490 lines (413 loc) · 18.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
"""Command-line interface for the GitCode SDK."""
import
argparse
import
codecs
import
inspect
import
json
import
re
import
sys
import
textwrap
from
collections
.
abc
import
Mapping
,
Sequence
from
pathlib
import
Path
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Union
,
get_args
,
get_origin
import
httpx
from
.
import
GitCode
,
__build_hash__
,
__version__
from
.
_base_client
import
DEFAULT_BASE_URL
,
DEFAULT_TOKEN_ENV
from
.
_cli_banner
import
format_default_welcome
from
.
_exceptions
import
GitCodeError
from
.
resources
.
_shared
import
SyncResource
class
_CLIHelpFormatter
(
argparse
.
RawDescriptionHelpFormatter
,
argparse
.
ArgumentDefaultsHelpFormatter
):
"""Preserve paragraph breaks in descriptions; wider columns for signatures."""
def
__init__
(
self
,
prog
:
str
)
->
None
:
super
().
__init__
(
prog
,
width
=
108
,
max_help_position
=
32
)
def
_plain_cli_inline
(
text
:
str
)
->
str
:
"""Strip Sphinx-style inline markup (roles, doubled literals) for terminal text."""
if
not
text
:
return
""
t
=
re
.
sub
(
r"``\s*([^`]+?)\s*``"
,
r"\1"
,
text
)
t
=
re
.
sub
(
r":\w+:`([^`]*)`"
,
r"\1"
,
t
)
t
=
re
.
sub
(
r"`([^`]+)`"
,
r"\1"
,
t
)
return
t
_ESCAPE_PATTERN
=
re
.
compile
(
r"\\\w+"
)
def
_unescape_input
(
value
:
str
,
replacements
:
Dict
[
str
,
str
])
->
str
:
"""Unescape CLI input with provided escape sequences."""
for
token
,
decoded
in
replacements
.
items
():
value
=
value
.
replace
(
token
,
decoded
)
return
value
def
_unescape_namespace
(
args
:
argparse
.
Namespace
)
->
None
:
mapping
=
((
token
,
codecs
.
decode
(
token
,
"unicode-escape"
))
for
token
in
_ESCAPE_PATTERN
.
findall
(
str
(
args
.
escape
)))
replacements
=
{
token
:
decoded
for
token
,
decoded
in
mapping
if
token
and
(
token
!=
decoded
)}
if
not
replacements
:
raise
argparse
.
ArgumentTypeError
(
"No valid escape sequence provided!"
)
for
key
,
value
in
vars
(
args
).
items
():
if
key
in
{
"escape"
,
"base_url"
,
"resource"
,
"method"
,
"api_key"
}:
continue
if
isinstance
(
value
,
str
):
setattr
(
args
,
key
,
_unescape_input
(
value
,
replacements
=
replacements
))
continue
if
isinstance
(
value
,
list
):
updated
=
[]
changed
=
False
for
item
in
value
:
if
isinstance
(
item
,
str
):
updated
.
append
(
_unescape_input
(
item
,
replacements
=
replacements
))
changed
=
True
else
:
updated
.
append
(
item
)
if
changed
:
setattr
(
args
,
key
,
updated
)
def
_unwrap_optional
(
annotation
:
Any
)
->
Any
:
origin
=
get_origin
(
annotation
)
if
origin
is
Union
:
args
=
[
arg
for
arg
in
get_args
(
annotation
)
if
arg
is
not
type
(
None
)]
if
len
(
args
)
==
1
:
return
args
[
0
]
return
annotation
def
_is_list_annotation
(
annotation
:
Any
)
->
bool
:
annotation
=
_unwrap_optional
(
annotation
)
return
get_origin
(
annotation
)
in
(
list
,
List
)
def
_list_item_type
(
annotation
:
Any
)
->
Any
:
annotation
=
_unwrap_optional
(
annotation
)
args
=
get_args
(
annotation
)
if
not
args
:
return
str
item_type
=
_unwrap_optional
(
args
[
0
])
if
item_type
in
(
int
,
float
):
return
item_type
return
str
def
_argument_kwargs
(
parameter
:
inspect
.
Parameter
)
->
dict
[
str
,
Any
]:
annotation
=
_unwrap_optional
(
parameter
.
annotation
)
if
annotation
is
bool
:
return
{
"action"
:
argparse
.
BooleanOptionalAction
,
"default"
:
parameter
.
default
}
if
_is_list_annotation
(
parameter
.
annotation
):
return
{
"nargs"
:
"+"
,
"type"
:
_list_item_type
(
parameter
.
annotation
),
"default"
:
None
}
if
annotation
in
(
int
,
float
):
return
{
"type"
:
annotation
}
return
{
"type"
:
str
}
def
_first_doc_line
(
obj
:
Any
)
->
str
:
doc
=
inspect
.
getdoc
(
obj
)
if
doc
is
not
None
:
doc
=
doc
.
removeprefix
(
"Synchronous "
).
capitalize
()
for
line
in
(
doc
or
""
).
splitlines
():
stripped
=
line
.
strip
()
if
stripped
:
return
_plain_cli_inline
(
stripped
)
return
""
def
_method_cli_summary
(
doc
:
str
)
->
str
:
"""Text before the first ':param' in the docstring, collapsed to one line for CLI help."""
return
doc
.
split
(
":param"
,
1
)[
0
].
strip
().
replace
(
"
\n
"
,
" "
)
def
_resource_types
()
->
dict
[
str
,
type
[
SyncResource
]]:
resources
:
dict
[
str
,
type
[
SyncResource
]]
=
{}
for
name
,
annotation
in
GitCode
.
__annotations__
.
items
():
if
inspect
.
isclass
(
annotation
)
and
issubclass
(
annotation
,
SyncResource
):
resources
[
name
]
=
annotation
return
resources
def
_probe_gitcode
()
->
GitCode
:
"""Lightweight client used only while building -h/--help metadata (no network)."""
transport
=
httpx
.
MockTransport
(
lambda
_request
:
httpx
.
Response
(
200
,
json
=
{}))
return
GitCode
(
api_key
=
"__cli_help__"
,
http_client
=
httpx
.
Client
(
transport
=
transport
))
def
_resource_commands_epilog
(
resource
:
SyncResource
)
->
str
:
"""List CLI subcommand names in the same order as resource.methods on the client."""
kebab_names
=
[
_kebab_case
(
name
)
for
name
in
resource
.
methods
]
joined
=
", "
.
join
(
kebab_names
)
wrapped
=
textwrap
.
fill
(
joined
,
width
=
120
,
initial_indent
=
" "
,
subsequent_indent
=
" "
,
break_long_words
=
False
,
break_on_hyphens
=
False
,
)
return
"Subcommands (stable SDK order, same as resource.methods):
\n
"
+
wrapped
def
_kebab_case
(
value
:
str
)
->
str
:
return
value
.
replace
(
"_"
,
"-"
)
def
_load_json_value
(
raw
:
str
)
->
Any
:
if
raw
.
startswith
(
"@"
):
return
json
.
loads
(
Path
(
raw
[
1
:]).
read_text
(
encoding
=
"utf-8"
))
return
json
.
loads
(
raw
)
def
_parse_scalar
(
raw
:
str
)
->
Any
:
try
:
return
_load_json_value
(
raw
)
except
(
OSError
,
ValueError
,
json
.
JSONDecodeError
):
return
raw
def
_parse_key_value
(
raw
:
str
)
->
tuple
[
str
,
Any
]:
if
"="
not
in
raw
:
raise
ValueError
(
f"Expected KEY=VALUE, got:
{
raw
}
"
)
key
,
value
=
raw
.
split
(
"="
,
maxsplit
=
1
)
if
not
key
:
raise
ValueError
(
f"Expected KEY=VALUE, got:
{
raw
}
"
)
return
key
,
_parse_scalar
(
value
)
def
_to_data
(
value
:
Any
)
->
Any
:
if
hasattr
(
value
,
"to_dict"
)
and
callable
(
value
.
to_dict
):
return
_to_data
(
value
.
to_dict
())
if
isinstance
(
value
,
Mapping
):
return
{
key
:
_to_data
(
item
)
for
key
,
item
in
value
.
items
()}
if
isinstance
(
value
,
list
):
return
[
_to_data
(
item
)
for
item
in
value
]
return
value
def
_write_output
(
value
:
Any
,
*
,
output_file
:
Optional
[
str
],
compact
:
bool
)
->
None
:
if
value
is
None
:
return
if
isinstance
(
value
,
bytes
):
if
output_file
:
Path
(
output_file
).
write_bytes
(
value
)
else
:
sys
.
stdout
.
buffer
.
write
(
value
)
return
payload
=
_to_data
(
value
)
if
isinstance
(
payload
,
str
):
text
=
payload
else
:
text
=
json
.
dumps
(
payload
,
indent
=
None
if
compact
else
2
,
ensure_ascii
=
True
,
sort_keys
=
True
)
if
output_file
:
Path
(
output_file
).
write_text
(
text
+
(
"
\n
"
if
not
text
.
endswith
(
"
\n
"
)
else
""
),
encoding
=
"utf-8"
)
else
:
print
(
text
)
def
_invocation_parent_parser
()
->
argparse
.
ArgumentParser
:
"""Parser with flags for real API calls (attached only to leaf METHOD parsers, not top-level usage)."""
parser
=
argparse
.
ArgumentParser
(
add_help
=
False
)
parser
.
add_argument
(
"--api-key"
,
help
=
f"GitCode access token. Defaults to
{
DEFAULT_TOKEN_ENV
}
."
)
parser
.
add_argument
(
"--base-url"
,
default
=
DEFAULT_BASE_URL
,
help
=
"Base URL for the REST API."
)
parser
.
add_argument
(
"--timeout"
,
type
=
float
,
default
=
None
,
help
=
"Request timeout in seconds."
)
parser
.
add_argument
(
"--output-file"
,
help
=
"Write the response to a file instead of stdout."
)
parser
.
add_argument
(
"--compact"
,
action
=
"store_true"
,
help
=
"Print JSON without indentation."
)
parser
.
add_argument
(
"-e"
,
"--escape"
,
default
=
""
,
metavar
=
"SEQUENCES"
,
help
=
'Unescape certain escape sequences (e.g. -e "
\\
n
\\
t") in arguments.'
,
)
return
parser
def
_root_banner
()
->
str
:
return
"Connection and defaults are documented on each method's help: %(prog)s RESOURCE METHOD -h."
def
_parse_true_false
(
raw
:
str
)
->
bool
:
value
=
raw
.
strip
().
lower
()
if
value
==
"true"
:
return
True
if
value
==
"false"
:
return
False
raise
argparse
.
ArgumentTypeError
(
"Expected 'true' or 'false'."
)
def
_serve_parser
()
->
argparse
.
ArgumentParser
:
"""Parser with options for starting the bundled MCP server."""
parser
=
argparse
.
ArgumentParser
(
add_help
=
False
)
parser
.
add_argument
(
"--name"
,
default
=
"GitCode API"
,
help
=
"MCP server name."
)
parser
.
add_argument
(
"--api-key"
,
help
=
f"GitCode access token. Defaults to
{
DEFAULT_TOKEN_ENV
}
."
)
parser
.
add_argument
(
"--owner"
,
help
=
"Default repository owner."
)
parser
.
add_argument
(
"--repo"
,
help
=
"Default repository name."
)
parser
.
add_argument
(
"--base-url"
,
default
=
DEFAULT_BASE_URL
,
help
=
"Base URL for the REST API."
)
parser
.
add_argument
(
"--timeout"
,
type
=
float
,
default
=
None
,
help
=
"Request timeout in seconds."
)
parser
.
add_argument
(
"--transport"
,
default
=
"stdio"
,
choices
=
(
"stdio"
,
"http"
,
"sse"
),
metavar
=
"{stdio,http,sse}"
,
help
=
"FastMCP transport to run, such as stdio or http."
,
)
parser
.
add_argument
(
"--host"
,
default
=
None
,
help
=
"Host for HTTP-based transports."
)
parser
.
add_argument
(
"--port"
,
type
=
int
,
default
=
None
,
help
=
"Port for HTTP-based transports."
)
parser
.
add_argument
(
"--path"
,
default
=
None
,
help
=
"Path for HTTP-based transports."
)
parser
.
add_argument
(
"-b"
,
"--show-banner"
,
type
=
_parse_true_false
,
choices
=
(
True
,
False
),
default
=
None
,
metavar
=
"{true,false}"
,
help
=
"Show the FastMCP startup banner."
,
)
return
parser
def
build_parser
()
->
argparse
.
ArgumentParser
:
"""Build main parser."""
common
=
_invocation_parent_parser
()
epilog
=
"""
\
Examples:
%(prog)s pulls list --api-key "$GITCODE_ACCESS_TOKEN" --owner my-org --repo my-repo
%(prog)s users me --api-key "$GITCODE_ACCESS_TOKEN"
%(prog)s pulls list --set only_count=true --set reviewer=demo
Extra keyword arguments (when needed):
Repeat --set key=value (value is JSON if it parses as JSON; otherwise a string).
--set-json merges one JSON object (or @path/to/file.json) into those kwargs.
Each resource -h lists subcommands in SDK order (resource.methods).
Each method -h opens with resource.method_signature("<name>") from the Python SDK.
"""
parser
=
argparse
.
ArgumentParser
(
prog
=
"gitcode-api"
,
usage
=
"%(prog)s [-h] [--version] RESOURCE ..."
,
description
=
_root_banner
(),
epilog
=
epilog
,
formatter_class
=
_CLIHelpFormatter
,
)
parser
.
add_argument
(
"--version"
,
action
=
"version"
,
version
=
f"%(prog)s
{
__version__
}
(build
{
__build_hash__
}
)"
)
client
=
_probe_gitcode
()
try
:
resource_parsers
=
parser
.
add_subparsers
(
dest
=
"resource"
,
required
=
True
,
metavar
=
"RESOURCE"
,
title
=
"commands"
,
description
=
"Pick a command or resource group (same attribute names as on GitCode, e.g. pulls, repos)."
,
)
serve_parser
=
resource_parsers
.
add_parser
(
"serve"
,
help
=
"Start the bundled GitCode MCP server."
,
description
=
"Start a FastMCP server exposing the gitcode_api_tool."
,
formatter_class
=
_CLIHelpFormatter
,
parents
=
[
_serve_parser
()],
)
serve_parser
.
set_defaults
(
command
=
"serve"
)
for
resource_name
,
resource_type
in
_resource_types
().
items
():
resource
=
getattr
(
client
,
resource_name
)
class_doc
=
inspect
.
getdoc
(
resource_type
)
if
class_doc
is
not
None
:
class_doc
=
class_doc
.
removeprefix
(
"Synchronous "
).
capitalize
()
class_lead
=
(
class_doc
or
""
).
split
(
"
\n
\n
"
,
maxsplit
=
1
)[
0
].
strip
()
if
class_doc
else
""
class_lead
=
_plain_cli_inline
(
class_lead
)
if
class_lead
else
""
resource_desc_parts
=
[
class_lead
or
_first_doc_line
(
resource_type
),
""
,
_resource_commands_epilog
(
resource
),
]
resource_parser
=
resource_parsers
.
add_parser
(
_kebab_case
(
resource_name
),
help
=
_first_doc_line
(
resource_type
)
or
f"GitCode
{
resource_name
}
endpoints."
,
description
=
"
\n
"
.
join
(
resource_desc_parts
),
formatter_class
=
_CLIHelpFormatter
,
)
method_parsers
=
resource_parser
.
add_subparsers
(
dest
=
"method"
,
required
=
True
,
title
=
"methods"
,
metavar
=
"METHOD"
,
description
=
(
"Method names use kebab-case. The opening line of each command's help matches "
"resource.method_signature('<name>') on the Python client."
),
)
for
method_name
in
resource
.
methods
:
method
=
getattr
(
resource
,
method_name
)
sig_line
=
resource
.
method_signature
(
method_name
)
doc
=
inspect
.
getdoc
(
method
)
if
doc
is
not
None
:
doc
=
doc
.
removeprefix
(
"Synchronous "
).
capitalize
()
summary
=
_method_cli_summary
(
doc
or
""
)
if
summary
and
len
(
summary
)
>
90
:
method_help
=
summary
[:
87
]
+
"..."
else
:
method_help
=
summary
or
(
sig_line
if
len
(
sig_line
)
<=
90
else
sig_line
[:
87
]
+
"..."
)
method_description
=
f"
{
summary
}
\n
\n
{
sig_line
}
"
if
summary
else
sig_line
method_parser
=
method_parsers
.
add_parser
(
_kebab_case
(
method_name
),
help
=
method_help
,
description
=
method_description
,
formatter_class
=
_CLIHelpFormatter
,
parents
=
[
common
],
)
signature
=
inspect
.
signature
(
method
)
for
parameter
in
signature
.
parameters
.
values
():
if
parameter
.
name
==
"self"
:
continue
if
parameter
.
kind
==
inspect
.
Parameter
.
VAR_KEYWORD
:
method_parser
.
add_argument
(
"--set"
,
dest
=
"extra_items"
,
action
=
"append"
,
default
=
None
,
metavar
=
"KEY=VALUE"
,
help
=
"Extra keyword arguments."
,
)
method_parser
.
add_argument
(
"--set-json"
,
dest
=
"extra_json"
,
default
=
None
,
metavar
=
"JSON_OR_@FILE"
,
help
=
"JSON object merged into extra keyword arguments."
,
)
continue
flag
=
f"--
{
parameter
.
name
.
replace
(
'_'
,
'-'
)
}
"
if
flag
in
method_parser
.
_option_string_actions
:
continue
kwargs
=
_argument_kwargs
(
parameter
)
kwargs
[
"dest"
]
=
parameter
.
name
kwargs
[
"required"
]
=
parameter
.
default
is
inspect
.
Signature
.
empty
method_parser
.
add_argument
(
flag
,
**
kwargs
)
method_parser
.
set_defaults
(
resource_name
=
resource_name
,
method_name
=
method_name
)
finally
:
client
.
close
()
return
parser
def
_run_mcp_server
(
args
:
argparse
.
Namespace
)
->
int
:
"""Start the bundled FastMCP server."""
from
.
llm
import
create_mcp_server
from
.
llm
.
_tool
import
GitCodeLLMTool
tool
=
GitCodeLLMTool
(
api_key
=
args
.
api_key
,
owner
=
args
.
owner
,
repo
=
args
.
repo
,
base_url
=
args
.
base_url
,
timeout
=
args
.
timeout
,
)
server
=
create_mcp_server
(
name
=
args
.
name
,
tool
=
tool
)
run_kwargs
:
dict
[
str
,
Any
]
=
{
"transport"
:
args
.
transport
}
for
key
in
(
"host"
,
"port"
,
"path"
):
value
=
getattr
(
args
,
key
)
if
value
is
not
None
:
run_kwargs
[
key
]
=
value
server
.
run
(
show_banner
=
args
.
show_banner
,
**
run_kwargs
)
return
0
def
_collect_kwargs
(
args
:
argparse
.
Namespace
,
method
:
Any
)
->
dict
[
str
,
Any
]:
signature
=
inspect
.
signature
(
method
)
kwargs
:
dict
[
str
,
Any
]
=
{}
for
parameter
in
signature
.
parameters
.
values
():
if
parameter
.
name
==
"self"
:
continue
if
parameter
.
kind
==
inspect
.
Parameter
.
VAR_KEYWORD
:
extra_kwargs
:
dict
[
str
,
Any
]
=
{}
if
getattr
(
args
,
"extra_json"
,
None
):
raw_extra
=
_load_json_value
(
args
.
extra_json
)
if
not
isinstance
(
raw_extra
,
dict
):
raise
ValueError
(
"--set-json must decode to a JSON object."
)
extra_kwargs
.
update
(
raw_extra
)
for
item
in
getattr
(
args
,
"extra_items"
, [])
or
[]:
key
,
value
=
_parse_key_value
(
item
)
extra_kwargs
[
key
]
=
value
kwargs
.
update
(
extra_kwargs
)
continue
value
=
getattr
(
args
,
parameter
.
name
)
if
value
is
None
:
if
parameter
.
default
is
inspect
.
Signature
.
empty
:
raise
ValueError
(
f"--
{
parameter
.
name
.
replace
(
'_'
,
'-'
)
}
is required."
)
continue
kwargs
[
parameter
.
name
]
=
value
return
kwargs
def
main
(
argv
:
Optional
[
Sequence
[
str
]]
=
None
)
->
int
:
"""CLI entry point."""
parser
=
build_parser
()
effective
=
list
(
sys
.
argv
[
1
:]
if
argv
is
None
else
argv
)
if
not
effective
:
print
(
format_default_welcome
(
__version__
,
__build_hash__
),
end
=
""
)
saved_epilog
=
parser
.
epilog
parser
.
epilog
=
None
try
:
parser
.
print_help
()
finally
:
parser
.
epilog
=
saved_epilog
return
0
args
=
parser
.
parse_args
(
effective
)
escape_seq
=
getattr
(
args
,
"escape"
,
None
)
if
escape_seq
and
isinstance
(
escape_seq
,
str
):
_unescape_namespace
(
args
)
try
:
if
getattr
(
args
,
"command"
,
None
)
==
"serve"
:
return
_run_mcp_server
(
args
)
with
GitCode
(
api_key
=
args
.
api_key
,
base_url
=
args
.
base_url
,
timeout
=
args
.
timeout
,
)
as
client
:
resource
=
getattr
(
client
,
args
.
resource_name
)
method
=
getattr
(
resource
,
args
.
method_name
)
result
=
method
(
**
_collect_kwargs
(
args
,
method
))
except
(
GitCodeError
,
ImportError
,
OSError
,
TypeError
,
ValueError
)
as
exc
:
# pragma: no cover - integration style
print
(
f"error:
{
exc
}
"
,
file
=
sys
.
stderr
)
return
1
_write_output
(
result
,
output_file
=
args
.
output_file
,
compact
=
args
.
compact
)
return
0
Back
|
FazBrowse Home
|
New Git URL