From 61483edc021c130ac584f4f6936d23a504a9416b Mon Sep 17 00:00:00 2001 From: Manoj Gowda Date: Mon, 24 Aug 2026 12:14:07 +0530 Subject: [PATCH] Drop -c short flag from --config-file to fix click warning The new --config-file option added in 1c04c47 declared -c as its short flag, colliding with the long-standing -c/--copyright option from the copyright scanner plugin. click warns about the duplicate parameter on every invocation: UserWarning: The parameter -c is used more than once. Remove its duplicate as parameters should be unique. Keep -c for --copyright and drop the short flag from --config-file, which has not shipped in a release yet. Regenerate the help test fixtures and update the docs pages that embed the help text. Reference: https://github.com/aboutcode-org/scancode-toolkit/issues/5265 Signed-off-by: Manoj Gowda --- .../scancode-cli/cli-help-text-options.rst | 2 +- docs/source/rst-snippets/cli-core-options.rst | 2 +- src/scancode/cli.py | 2 +- tests/scancode/data/help/help.txt | 45 +++++++++---------- tests/scancode/data/help/help_linux.txt | 45 +++++++++---------- 5 files changed, 47 insertions(+), 49 deletions(-) diff --git a/docs/source/reference/scancode-cli/cli-help-text-options.rst b/docs/source/reference/scancode-cli/cli-help-text-options.rst index bd85727387..caa0a03636 100644 --- a/docs/source/reference/scancode-cli/cli-help-text-options.rst +++ b/docs/source/reference/scancode-cli/cli-help-text-options.rst @@ -173,7 +173,7 @@ The following help text is displayed for ScanCode version 32.0.0: -n, --processes INT Set the number of parallel processes to use. Disable parallel processing if 0. Also disable threading if -1. [default: (number of CPUs)-1] - -c, --config-file FILENAME Path to the configuration file. + --config-file FILENAME Path to the configuration file. -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. diff --git a/docs/source/rst-snippets/cli-core-options.rst b/docs/source/rst-snippets/cli-core-options.rst index 0f589b2c6c..1532ccc5fe 100644 --- a/docs/source/rst-snippets/cli-core-options.rst +++ b/docs/source/rst-snippets/cli-core-options.rst @@ -7,7 +7,7 @@ Default: ``(number of CPUs)-1`` --c, --config-file FILENAME Path to the configuration file. +--config-file FILENAME Path to the configuration file. -v, --verbose Print verbose file-by-file progress messages. -q, --quiet Do not print summary or progress messages. diff --git a/src/scancode/cli.py b/src/scancode/cli.py index f7fe221c21..b3db9ac573 100644 --- a/src/scancode/cli.py +++ b/src/scancode/cli.py @@ -233,7 +233,7 @@ def default_processes(): cls=PluggableCommandLineOption, ) -@click.option('-c', '--config-file', +@click.option('--config-file', type=click.File('r'), required=False, help='Path to the configuration file.', diff --git a/tests/scancode/data/help/help.txt b/tests/scancode/data/help/help.txt index 52bc2e0ce7..866802346a 100644 --- a/tests/scancode/data/help/help.txt +++ b/tests/scancode/data/help/help.txt @@ -136,29 +136,28 @@ Options: which are todo items and needs manual review. core: - --ignore Ignore files matching . - --timeout Stop an unfinished file scan after a timeout in - seconds. [default: 120 seconds] - -n, --processes INT Set the number of parallel processes to use. - Disable parallel processing if 0. Also disable - threading if -1. [default: (number of CPUs)-1] - -c, --config-file FILENAME Path to the configuration file. - -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 JSON scan - file(s). - --max-in-memory INTEGER Maximum number of files and directories scan - details kept in memory during a scan. Additional - files and directories scan details above this - number are cached on-disk rather than in memory. - Use 0 to use unlimited memory and disable on-disk - caching. Use -1 to use only on-disk caching. - [default: 10000] - --max-depth INTEGER Maximum nesting depth of subdirectories to scan. - Descend at most INTEGER levels of directories - below and including the starting directory. Use 0 - for no scan depth limit. + --ignore Ignore files matching . + --timeout Stop an unfinished file scan after a timeout in + seconds. [default: 120 seconds] + -n, --processes INT Set the number of parallel processes to use. Disable + parallel processing if 0. Also disable threading if + -1. [default: (number of CPUs)-1] + --config-file FILENAME Path to the configuration file. + -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 JSON scan + file(s). + --max-in-memory INTEGER Maximum number of files and directories scan details + kept in memory during a scan. Additional files and + directories scan details above this number are cached + on-disk rather than in memory. Use 0 to use unlimited + memory and disable on-disk caching. Use -1 to use + only on-disk caching. [default: 10000] + --max-depth INTEGER Maximum nesting depth of subdirectories to scan. + Descend at most INTEGER levels of directories below + and including the starting directory. Use 0 for no + scan depth limit. documentation: -h, --help Show this message and exit. diff --git a/tests/scancode/data/help/help_linux.txt b/tests/scancode/data/help/help_linux.txt index 9630f39fb0..22ea0906a8 100644 --- a/tests/scancode/data/help/help_linux.txt +++ b/tests/scancode/data/help/help_linux.txt @@ -138,29 +138,28 @@ Options: which are todo items and needs manual review. core: - --ignore Ignore files matching . - --timeout Stop an unfinished file scan after a timeout in - seconds. [default: 120 seconds] - -n, --processes INT Set the number of parallel processes to use. - Disable parallel processing if 0. Also disable - threading if -1. [default: (number of CPUs)-1] - -c, --config-file FILENAME Path to the configuration file. - -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 JSON scan - file(s). - --max-in-memory INTEGER Maximum number of files and directories scan - details kept in memory during a scan. Additional - files and directories scan details above this - number are cached on-disk rather than in memory. - Use 0 to use unlimited memory and disable on-disk - caching. Use -1 to use only on-disk caching. - [default: 10000] - --max-depth INTEGER Maximum nesting depth of subdirectories to scan. - Descend at most INTEGER levels of directories - below and including the starting directory. Use 0 - for no scan depth limit. + --ignore Ignore files matching . + --timeout Stop an unfinished file scan after a timeout in + seconds. [default: 120 seconds] + -n, --processes INT Set the number of parallel processes to use. Disable + parallel processing if 0. Also disable threading if + -1. [default: (number of CPUs)-1] + --config-file FILENAME Path to the configuration file. + -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 JSON scan + file(s). + --max-in-memory INTEGER Maximum number of files and directories scan details + kept in memory during a scan. Additional files and + directories scan details above this number are cached + on-disk rather than in memory. Use 0 to use unlimited + memory and disable on-disk caching. Use -1 to use + only on-disk caching. [default: 10000] + --max-depth INTEGER Maximum nesting depth of subdirectories to scan. + Descend at most INTEGER levels of directories below + and including the starting directory. Use 0 for no + scan depth limit. documentation: -h, --help Show this message and exit.