Skip to content

Commit

Permalink
Merge pull request #2858 from KevinJi22/version-output-2856
Browse files Browse the repository at this point in the history
Make --version output valid YAML for parsing #2856
  • Loading branch information
pombredanne committed Feb 8, 2022
2 parents 4bd9c8e + b78b49f commit cec5846
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/scancode/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ def print_examples(ctx, param, value):
def print_version(ctx, param, value):
if not value or ctx.resilient_parsing:
return
click.echo('ScanCode version ' + scancode_config.__version__)
click.echo('ScanCode Output Format version ' + scancode_config.__output_format_version__)
click.echo('SPDX License list version ' + scancode_config.spdx_license_list_version)
click.echo(f'ScanCode version: {scancode_config.__version__}')
click.echo(f'ScanCode Output Format version: {scancode_config.__output_format_version__}')
click.echo(f'SPDX License list version: {scancode_config.spdx_license_list_version}')
ctx.exit()


Expand Down
11 changes: 11 additions & 0 deletions tests/scancode/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,3 +929,14 @@ def test_VirtualCodebase_output_with_from_json_is_same_as_original():

assert json.dumps(results , indent=2) == json.dumps(expected, indent=2)
assert len(results_headers) == len(expected_headers) + 1

def test_getting_version_returns_valid_yaml():
import saneyaml
import scancode_config
args = ['--version']
result = run_scan_click(args)
assert saneyaml.load(result.output) == {
'ScanCode version': f'{scancode_config.__version__}',
'ScanCode Output Format version': f'{scancode_config.__output_format_version__}',
'SPDX License list version': f'{scancode_config.spdx_license_list_version}'
}

0 comments on commit cec5846

Please sign in to comment.