-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcli.py
More file actions
56 lines (43 loc) · 1.32 KB
/
Copy pathcli.py
File metadata and controls
56 lines (43 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# FederatedCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/federatedcode for support or download.
# See https://aboutcode.org for more information about AboutCode.org OSS projects.
#
import click
from aboutcode.federatedcode import client
@click.group()
def handler():
pass
@click.command()
@click.argument("purl")
def scan(purl):
"""
Get package scan for PURL from FederatedCode git repository.
PURL: PURL to fetch scan result
"""
click.echo(client.get_package_scan(purl=purl))
@click.command()
@click.argument("purl")
def discover(purl):
"""
Discover existing Packages in the FederatedCode AP server.
PURL: PURL to find in AP server
"""
if response := client.discover_package_in_ap_server(purl=purl):
click.echo(click.style(response, fg="green", bold=True))
else:
click.echo(
click.style(
f"Error: {purl} not available on {client.FEDERATEDCODE_AP_HOST} AP server.",
fg="red",
bold=True,
)
)
handler.add_command(scan)
handler.add_command(discover)
if __name__ == "__main__":
handler()