Skip to content

Commit

Permalink
Support shortcut flags for cli
Browse files Browse the repository at this point in the history
Signed-off-by: Akhil Raj <[email protected]>
  • Loading branch information
lf32 committed May 31, 2022
1 parent ca7fb71 commit e6e0602
Show file tree
Hide file tree
Showing 14 changed files with 1,378 additions and 17 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The following organizations or individuals have contributed to ScanCode:
- Johannes Najjar @joshovi
- Jose Nazario @paralax
- Kevin Ji @KevinJi22
- Lali Akhil Raj @lf32
- Lemo Shi @lemoshi
- Li Ha @linexb
- Mankaran Singh @MankaranSingh
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,15 @@ Development environment changes:
environment variable. There is no need to replace the regen=False with regen=True
in the code.

Miscellaneous
--------------

- Added support for usage of shortcut flags
- `-A` or `--about`
- `-q` or `--quiet`
- `-v` or `--verbose`
- `-V` or `--version` can be used.


30.1.0 - 2021-09-25
--------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/source/rst_snippets/core_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ All "Core" Scan Options
-n, --processes INTEGER Scan ``<input>`` using n parallel processes.
[Default: 1]

--verbose Print verbose file-by-file progress messages.
-v, --verbose Print verbose file-by-file progress messages.

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

--timeout FLOAT Stop scanning a file if scanning takes longer
than a timeout in seconds. [Default: 120]
Expand Down
8 changes: 4 additions & 4 deletions src/scancode/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ def validate_depth(ctx, param, value):
f'[default: {DEFAULT_TIMEOUT} seconds]',
help_group=cliutils.CORE_GROUP, sort_order=10, cls=PluggableCommandLineOption)

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

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

@click.option('--about',
@click.option('-A', '--about',
is_flag=True,
is_eager=True,
expose_value=False,
callback=print_about,
help='Show information about ScanCode and licensing and exit.',
help_group=cliutils.DOC_GROUP, sort_order=20, cls=PluggableCommandLineOption)

@click.option('--version',
@click.option('-V', '--version',
is_flag=True,
is_eager=True,
expose_value=False,
Expand Down
8 changes: 4 additions & 4 deletions tests/scancode/data/help/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ Options:
-n, --processes INT Set the number of parallel processes to use. Disable
parallel processing if 0. Also disable threading if
-1. [default: 1]
--quiet Do not print summary or progress.
--verbose Print progress as file-by-file path instead of a
-q, --quiet Do not print summary or progress.
-v, --verbose Print progress as file-by-file path instead of a
progress bar. Print verbose scan counters.
--from-json Load codebase from one or more <input> JSON scan
file(s).
Expand All @@ -161,8 +161,8 @@ Options:

documentation:
-h, --help Show this message and exit.
--about Show information about ScanCode and licensing and exit.
--version Show the version and exit.
-A, --about Show information about ScanCode and licensing and exit.
-V, --version Show the version and exit.
--examples Show command examples and exit.
--list-packages Show the list of supported package manifest parsers and exit.
--plugins Show the list of available ScanCode plugins and exit.
Expand Down
175 changes: 175 additions & 0 deletions tests/scancode/data/unicodepath/unicodepath.expected-linux.json-q
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
{
"headers": [
{
"tool_name": "scancode-toolkit",
"options": {
"input": "<path>",
"--copyright": true,
"--email": true,
"--info": true,
"--json": "<file>",
"--license": true,
"--package": true,
"--quiet": true,
"--strip-root": true,
"--url": true
},
"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.",
"output_format_version": "2.0.0",
"message": null,
"errors": [],
"warnings": [],
"extra_data": {
"system_environment": {
"operating_system": "linux",
"cpu_architecture": "64",
"platform": "Linux-5.4.0-109-generic-x86_64-with-Ubuntu-18.04-bionic",
"platform_version": "#123~18.04.1-Ubuntu SMP Fri Apr 8 09:48:52 UTC 2022",
"python_version": "3.6.9 (default, Mar 15 2022, 13:55:28) \n[GCC 8.4.0]"
},
"spdx_license_list_version": "3.16",
"files_count": 3
}
}
],
"dependencies": [],
"packages": [],
"files": [
{
"path": "unicodepath",
"type": "directory",
"name": "unicodepath",
"base_name": "unicodepath",
"extension": "",
"size": 0,
"sha1": null,
"md5": null,
"sha256": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
"is_binary": false,
"is_text": false,
"is_archive": false,
"is_media": false,
"is_source": false,
"is_script": false,
"licenses": [],
"license_expressions": [],
"percentage_of_license_text": 0,
"copyrights": [],
"holders": [],
"authors": [],
"package_data": [],
"for_packages": [],
"emails": [],
"urls": [],
"files_count": 3,
"dirs_count": 0,
"size_count": 20,
"scan_errors": []
},
{
"path": "unicodepath/Izgradnja sufiksnog polja kori\u0161tenjem K\u00e4rkk\u00e4inen \u2013 Sandersovog algoritma.pdf",
"type": "file",
"name": "Izgradnja sufiksnog polja kori\u0161tenjem K\u00e4rkk\u00e4inen \u2013 Sandersovog algoritma.pdf",
"base_name": "Izgradnja sufiksnog polja kori\u0161tenjem K\u00e4rkk\u00e4inen \u2013 Sandersovog algoritma",
"extension": ".pdf",
"size": 2,
"sha1": "71853c6197a6a7f222db0f1978c7cb232b87c5ee",
"md5": "e1c06d85ae7b8b032bef47e42e4c08f9",
"sha256": "75a11da44c802486bc6f65640aa48a730f0f684c5c07a42ba3cd1735eb3fb070",
"mime_type": "text/plain",
"file_type": "ASCII text",
"programming_language": null,
"is_binary": false,
"is_text": true,
"is_archive": false,
"is_media": false,
"is_source": false,
"is_script": false,
"licenses": [],
"license_expressions": [],
"percentage_of_license_text": 0,
"copyrights": [],
"holders": [],
"authors": [],
"package_data": [],
"for_packages": [],
"emails": [],
"urls": [],
"files_count": 0,
"dirs_count": 0,
"size_count": 0,
"scan_errors": []
},
{
"path": "unicodepath/\u03e8\u1f40\u2328",
"type": "file",
"name": "\u03e8\u1f40\u2328",
"base_name": "\u03e8\u1f40\u2328",
"extension": "",
"size": 9,
"sha1": "37aa63c77398d954473262e1a0057c1e632eda77",
"md5": "552e21cd4cd9918678e3c1a0df491bc3",
"sha256": "b94f6f125c79e3a5ffaa826f584c10d52ada669e6762051b826b55776d05aed2",
"mime_type": "text/plain",
"file_type": "ASCII text, with no line terminators",
"programming_language": null,
"is_binary": false,
"is_text": true,
"is_archive": false,
"is_media": false,
"is_source": false,
"is_script": false,
"licenses": [],
"license_expressions": [],
"percentage_of_license_text": 0,
"copyrights": [],
"holders": [],
"authors": [],
"package_data": [],
"for_packages": [],
"emails": [],
"urls": [],
"files_count": 0,
"dirs_count": 0,
"size_count": 0,
"scan_errors": []
},
{
"path": "unicodepath/\u03e8\u1f40\u2328a",
"type": "file",
"name": "\u03e8\u1f40\u2328a",
"base_name": "\u03e8\u1f40\u2328a",
"extension": "",
"size": 9,
"sha1": "37aa63c77398d954473262e1a0057c1e632eda77",
"md5": "552e21cd4cd9918678e3c1a0df491bc3",
"sha256": "b94f6f125c79e3a5ffaa826f584c10d52ada669e6762051b826b55776d05aed2",
"mime_type": "text/plain",
"file_type": "ASCII text, with no line terminators",
"programming_language": null,
"is_binary": false,
"is_text": true,
"is_archive": false,
"is_media": false,
"is_source": false,
"is_script": false,
"licenses": [],
"license_expressions": [],
"percentage_of_license_text": 0,
"copyrights": [],
"holders": [],
"authors": [],
"package_data": [],
"for_packages": [],
"emails": [],
"urls": [],
"files_count": 0,
"dirs_count": 0,
"size_count": 0,
"scan_errors": []
}
]
}
Loading

0 comments on commit e6e0602

Please sign in to comment.