Skip to content

Commit cec5846

Browse files
authored
Merge pull request #2858 from KevinJi22/version-output-2856
Make --version output valid YAML for parsing #2856
2 parents 4bd9c8e + b78b49f commit cec5846

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/scancode/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ def print_examples(ctx, param, value):
9393
def print_version(ctx, param, value):
9494
if not value or ctx.resilient_parsing:
9595
return
96-
click.echo('ScanCode version ' + scancode_config.__version__)
97-
click.echo('ScanCode Output Format version ' + scancode_config.__output_format_version__)
98-
click.echo('SPDX License list version ' + scancode_config.spdx_license_list_version)
96+
click.echo(f'ScanCode version: {scancode_config.__version__}')
97+
click.echo(f'ScanCode Output Format version: {scancode_config.__output_format_version__}')
98+
click.echo(f'SPDX License list version: {scancode_config.spdx_license_list_version}')
9999
ctx.exit()
100100

101101

tests/scancode/test_cli.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,3 +929,14 @@ def test_VirtualCodebase_output_with_from_json_is_same_as_original():
929929

930930
assert json.dumps(results , indent=2) == json.dumps(expected, indent=2)
931931
assert len(results_headers) == len(expected_headers) + 1
932+
933+
def test_getting_version_returns_valid_yaml():
934+
import saneyaml
935+
import scancode_config
936+
args = ['--version']
937+
result = run_scan_click(args)
938+
assert saneyaml.load(result.output) == {
939+
'ScanCode version': f'{scancode_config.__version__}',
940+
'ScanCode Output Format version': f'{scancode_config.__output_format_version__}',
941+
'SPDX License list version': f'{scancode_config.spdx_license_list_version}'
942+
}

0 commit comments

Comments
 (0)