|
2 | 2 | # |
3 | 3 | # SPDX-License-Identifier: LGPL-2.1-or-later |
4 | 4 | # |
5 | | -# Copyright (C) 2022 Collabora Limited |
| 5 | +# Copyright (C) 2022, 2023 Collabora Limited |
6 | 6 | # Author: Guillaume Tucker <guillaume.tucker@collabora.com> |
7 | 7 |
|
8 | 8 | """KernelCI Command Line Tool |
9 | 9 |
|
10 | | -This executable script is the entry point for all the new KernelCI command line |
11 | | -tools which support the new API & Pipeline design. See the documentation for |
12 | | -more details: https://kernelci.org/docs/api/. |
| 10 | +This executable module is the entry point for the kci command line tool. It |
| 11 | +provides a way to manually interact with the KernelCI API and its related |
| 12 | +features. See the online documentation for more details: |
| 13 | +https://kernelci.org/docs/api/. |
13 | 14 | """ |
14 | 15 |
|
15 | | -import argparse |
16 | | -import sys |
| 16 | +import json |
17 | 17 |
|
18 | | -import kernelci.legacy.cli |
| 18 | +import click |
| 19 | + |
| 20 | +from kernelci.cli import Args, kci, KciS |
| 21 | +import kernelci.api |
| 22 | +import kernelci.config |
| 23 | + |
| 24 | + |
| 25 | +@kci.command(cls=KciS) |
| 26 | +@Args.config |
| 27 | +@Args.api |
| 28 | +def whoami(config, api, secrets): |
| 29 | + """Use whoami to get current user info with API authentication""" |
| 30 | + configs = kernelci.config.load(config) |
| 31 | + api_config = configs['api_configs'][api] |
| 32 | + api = kernelci.api.get_api(api_config, secrets.api.token) |
| 33 | + data = api.whoami() |
| 34 | + click.echo(json.dumps(data, indent=2)) |
19 | 35 |
|
20 | 36 |
|
21 | 37 | if __name__ == '__main__': |
22 | | - parser = argparse.ArgumentParser("KernelCI Command Line Tools") |
23 | | - parser.add_argument( |
24 | | - 'command', |
25 | | - choices=kernelci.legacy.cli.list_command_names(), |
26 | | - help="Command to run" |
27 | | - ) |
28 | | - args = parser.parse_args(sys.argv[1:2]) |
29 | | - kernelci.legacy.cli.call(args.command, sys.argv[2:]) |
| 38 | + kci() # pylint: disable=no-value-for-parameter |
0 commit comments