Skip to content

Commit d7c3e7d

Browse files
committed
Support shortcut flags for cli
support flags like -A, -q, -v, -V Signed-off-by: lf32 <96695352+lf32@users.noreply.github.com>
1 parent ca7fb71 commit d7c3e7d

14 files changed

+1378
-17
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The following organizations or individuals have contributed to ScanCode:
55
- Aditya Viki @adityaviki
66
- Agni Bhattacharyya @PyAgni
77
- Akanksha Garg @akugarg
8+
- Akhil Raj @lf32
89
- Alex Blekhman @a-tinsmith
910
- Alexander Gschrei @agschrei
1011
- Armijn Hemmel @armijnhemel

CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,15 @@ Development environment changes:
287287
environment variable. There is no need to replace the regen=False with regen=True
288288
in the code.
289289

290+
Miscellaneous
291+
--------------
292+
293+
- Added support for usage of shortcut flags
294+
- `-A` or `--about`
295+
- `-q` or `--quiet`
296+
- `-v` or `--verbose`
297+
- `-V` or `--version` can be used.
298+
290299

291300
30.1.0 - 2021-09-25
292301
--------------------

docs/source/rst_snippets/core_options.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ All "Core" Scan Options
44
-n, --processes INTEGER Scan ``<input>`` using n parallel processes.
55
[Default: 1]
66

7-
--verbose Print verbose file-by-file progress messages.
7+
-v, --verbose Print verbose file-by-file progress messages.
88

9-
--quiet Do not print summary or progress messages.
9+
-q, --quiet Do not print summary or progress messages.
1010

1111
--timeout FLOAT Stop scanning a file if scanning takes longer
1212
than a timeout in seconds. [Default: 120]

src/scancode/cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ def validate_depth(ctx, param, value):
211211
f'[default: {DEFAULT_TIMEOUT} seconds]',
212212
help_group=cliutils.CORE_GROUP, sort_order=10, cls=PluggableCommandLineOption)
213213

214-
@click.option('--quiet',
214+
@click.option('-q', '--quiet',
215215
is_flag=True,
216216
conflicting_options=['verbose'],
217217
help='Do not print summary or progress.',
218218
help_group=cliutils.CORE_GROUP, sort_order=20, cls=PluggableCommandLineOption)
219219

220-
@click.option('--verbose',
220+
@click.option('-v', '--verbose',
221221
is_flag=True,
222222
conflicting_options=['quiet'],
223223
help='Print progress as file-by-file path instead of a progress bar. '
@@ -258,15 +258,15 @@ def validate_depth(ctx, param, value):
258258
@click.help_option('-h', '--help',
259259
help_group=cliutils.DOC_GROUP, sort_order=10, cls=PluggableCommandLineOption)
260260

261-
@click.option('--about',
261+
@click.option('-A', '--about',
262262
is_flag=True,
263263
is_eager=True,
264264
expose_value=False,
265265
callback=print_about,
266266
help='Show information about ScanCode and licensing and exit.',
267267
help_group=cliutils.DOC_GROUP, sort_order=20, cls=PluggableCommandLineOption)
268268

269-
@click.option('--version',
269+
@click.option('-V', '--version',
270270
is_flag=True,
271271
is_eager=True,
272272
expose_value=False,

tests/scancode/data/help/help.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ Options:
136136
-n, --processes INT Set the number of parallel processes to use. Disable
137137
parallel processing if 0. Also disable threading if
138138
-1. [default: 1]
139-
--quiet Do not print summary or progress.
140-
--verbose Print progress as file-by-file path instead of a
139+
-q, --quiet Do not print summary or progress.
140+
-v, --verbose Print progress as file-by-file path instead of a
141141
progress bar. Print verbose scan counters.
142142
--from-json Load codebase from one or more <input> JSON scan
143143
file(s).
@@ -161,8 +161,8 @@ Options:
161161

162162
documentation:
163163
-h, --help Show this message and exit.
164-
--about Show information about ScanCode and licensing and exit.
165-
--version Show the version and exit.
164+
-A, --about Show information about ScanCode and licensing and exit.
165+
-V, --version Show the version and exit.
166166
--examples Show command examples and exit.
167167
--list-packages Show the list of supported package manifest parsers and exit.
168168
--plugins Show the list of available ScanCode plugins and exit.
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
{
2+
"headers": [
3+
{
4+
"tool_name": "scancode-toolkit",
5+
"options": {
6+
"input": "<path>",
7+
"--copyright": true,
8+
"--email": true,
9+
"--info": true,
10+
"--json": "<file>",
11+
"--license": true,
12+
"--package": true,
13+
"--quiet": true,
14+
"--strip-root": true,
15+
"--url": true
16+
},
17+
"notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.",
18+
"output_format_version": "2.0.0",
19+
"message": null,
20+
"errors": [],
21+
"warnings": [],
22+
"extra_data": {
23+
"system_environment": {
24+
"operating_system": "linux",
25+
"cpu_architecture": "64",
26+
"platform": "Linux-5.4.0-109-generic-x86_64-with-Ubuntu-18.04-bionic",
27+
"platform_version": "#123~18.04.1-Ubuntu SMP Fri Apr 8 09:48:52 UTC 2022",
28+
"python_version": "3.6.9 (default, Mar 15 2022, 13:55:28) \n[GCC 8.4.0]"
29+
},
30+
"spdx_license_list_version": "3.16",
31+
"files_count": 3
32+
}
33+
}
34+
],
35+
"dependencies": [],
36+
"packages": [],
37+
"files": [
38+
{
39+
"path": "unicodepath",
40+
"type": "directory",
41+
"name": "unicodepath",
42+
"base_name": "unicodepath",
43+
"extension": "",
44+
"size": 0,
45+
"sha1": null,
46+
"md5": null,
47+
"sha256": null,
48+
"mime_type": null,
49+
"file_type": null,
50+
"programming_language": null,
51+
"is_binary": false,
52+
"is_text": false,
53+
"is_archive": false,
54+
"is_media": false,
55+
"is_source": false,
56+
"is_script": false,
57+
"licenses": [],
58+
"license_expressions": [],
59+
"percentage_of_license_text": 0,
60+
"copyrights": [],
61+
"holders": [],
62+
"authors": [],
63+
"package_data": [],
64+
"for_packages": [],
65+
"emails": [],
66+
"urls": [],
67+
"files_count": 3,
68+
"dirs_count": 0,
69+
"size_count": 20,
70+
"scan_errors": []
71+
},
72+
{
73+
"path": "unicodepath/Izgradnja sufiksnog polja kori\u0161tenjem K\u00e4rkk\u00e4inen \u2013 Sandersovog algoritma.pdf",
74+
"type": "file",
75+
"name": "Izgradnja sufiksnog polja kori\u0161tenjem K\u00e4rkk\u00e4inen \u2013 Sandersovog algoritma.pdf",
76+
"base_name": "Izgradnja sufiksnog polja kori\u0161tenjem K\u00e4rkk\u00e4inen \u2013 Sandersovog algoritma",
77+
"extension": ".pdf",
78+
"size": 2,
79+
"sha1": "71853c6197a6a7f222db0f1978c7cb232b87c5ee",
80+
"md5": "e1c06d85ae7b8b032bef47e42e4c08f9",
81+
"sha256": "75a11da44c802486bc6f65640aa48a730f0f684c5c07a42ba3cd1735eb3fb070",
82+
"mime_type": "text/plain",
83+
"file_type": "ASCII text",
84+
"programming_language": null,
85+
"is_binary": false,
86+
"is_text": true,
87+
"is_archive": false,
88+
"is_media": false,
89+
"is_source": false,
90+
"is_script": false,
91+
"licenses": [],
92+
"license_expressions": [],
93+
"percentage_of_license_text": 0,
94+
"copyrights": [],
95+
"holders": [],
96+
"authors": [],
97+
"package_data": [],
98+
"for_packages": [],
99+
"emails": [],
100+
"urls": [],
101+
"files_count": 0,
102+
"dirs_count": 0,
103+
"size_count": 0,
104+
"scan_errors": []
105+
},
106+
{
107+
"path": "unicodepath/\u03e8\u1f40\u2328",
108+
"type": "file",
109+
"name": "\u03e8\u1f40\u2328",
110+
"base_name": "\u03e8\u1f40\u2328",
111+
"extension": "",
112+
"size": 9,
113+
"sha1": "37aa63c77398d954473262e1a0057c1e632eda77",
114+
"md5": "552e21cd4cd9918678e3c1a0df491bc3",
115+
"sha256": "b94f6f125c79e3a5ffaa826f584c10d52ada669e6762051b826b55776d05aed2",
116+
"mime_type": "text/plain",
117+
"file_type": "ASCII text, with no line terminators",
118+
"programming_language": null,
119+
"is_binary": false,
120+
"is_text": true,
121+
"is_archive": false,
122+
"is_media": false,
123+
"is_source": false,
124+
"is_script": false,
125+
"licenses": [],
126+
"license_expressions": [],
127+
"percentage_of_license_text": 0,
128+
"copyrights": [],
129+
"holders": [],
130+
"authors": [],
131+
"package_data": [],
132+
"for_packages": [],
133+
"emails": [],
134+
"urls": [],
135+
"files_count": 0,
136+
"dirs_count": 0,
137+
"size_count": 0,
138+
"scan_errors": []
139+
},
140+
{
141+
"path": "unicodepath/\u03e8\u1f40\u2328a",
142+
"type": "file",
143+
"name": "\u03e8\u1f40\u2328a",
144+
"base_name": "\u03e8\u1f40\u2328a",
145+
"extension": "",
146+
"size": 9,
147+
"sha1": "37aa63c77398d954473262e1a0057c1e632eda77",
148+
"md5": "552e21cd4cd9918678e3c1a0df491bc3",
149+
"sha256": "b94f6f125c79e3a5ffaa826f584c10d52ada669e6762051b826b55776d05aed2",
150+
"mime_type": "text/plain",
151+
"file_type": "ASCII text, with no line terminators",
152+
"programming_language": null,
153+
"is_binary": false,
154+
"is_text": true,
155+
"is_archive": false,
156+
"is_media": false,
157+
"is_source": false,
158+
"is_script": false,
159+
"licenses": [],
160+
"license_expressions": [],
161+
"percentage_of_license_text": 0,
162+
"copyrights": [],
163+
"holders": [],
164+
"authors": [],
165+
"package_data": [],
166+
"for_packages": [],
167+
"emails": [],
168+
"urls": [],
169+
"files_count": 0,
170+
"dirs_count": 0,
171+
"size_count": 0,
172+
"scan_errors": []
173+
}
174+
]
175+
}

0 commit comments

Comments
 (0)