Skip to content

Commit e0f0e25

Browse files
committedJan 7, 2024
refactor cli tools entry points
1 parent b259a1f commit e0f0e25

File tree

6 files changed

+9
-14
lines changed

6 files changed

+9
-14
lines changed
 

‎nested_diff/cli.py

+5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ def _decode_fmt_opts(opts):
5454
import json
5555
return json.loads(opts)
5656

57+
@classmethod
58+
def cli(cls):
59+
"""Cli tool entry point."""
60+
return cls().run()
61+
5762
@property
5863
def dumper(self): # noqa D102
5964
try:

‎nested_diff/diff_tool.py

-5
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,3 @@ def get_opts(opts):
332332
"""
333333
opts.setdefault('sort_keys', True)
334334
return opts
335-
336-
337-
def cli():
338-
"""Cli tool entry point."""
339-
return App().run()

‎nested_diff/patch_tool.py

-5
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,3 @@ def run(self):
8686
self.args.target_file.truncate()
8787

8888
return 0
89-
90-
91-
def cli():
92-
"""Cli tool entry point."""
93-
return App().run()

‎setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
packages=['nested_diff'],
4343
entry_points={
4444
'console_scripts': [
45-
'nested_diff=nested_diff.diff_tool:cli',
46-
'nested_patch=nested_diff.patch_tool:cli',
45+
'nested_diff=nested_diff.diff_tool:App.cli',
46+
'nested_patch=nested_diff.patch_tool:App.cli',
4747
],
4848
},
4949
extras_require={

‎tests/cli/test_diff_tool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def test_exit_code_diff_absent_U_opt_enabled(rpath): # noqa N802
398398
def test_entry_point(capsys):
399399
with mock.patch('sys.argv', ['nested_diff', '-h']):
400400
with pytest.raises(SystemExit) as e:
401-
nested_diff.diff_tool.cli()
401+
nested_diff.diff_tool.App.cli()
402402

403403
assert e.value.code == 0
404404

‎tests/cli/test_patch_tool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def test_toml_fmt(capsys, content, rpath, tmp_path):
155155
def test_entry_point(capsys):
156156
with mock.patch('sys.argv', ['nested_patch', '-h']):
157157
with pytest.raises(SystemExit) as e:
158-
nested_diff.patch_tool.cli()
158+
nested_diff.patch_tool.App.cli()
159159

160160
assert e.value.code == 0
161161

0 commit comments

Comments
 (0)
Failed to load comments.