Coverage for /Users/buh/.pyenv/versions/3.12.2/envs/pii/lib/python3.12/site-packages/es_pii_tool/cli.py: 0%

22 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-10-01 12:24 -0600

1"""Command-line interface""" 

2 

3import click 

4from es_client.defaults import OPTION_DEFAULTS, SHOW_EVERYTHING 

5from es_client.helpers import config as cfg 

6from es_client.helpers.logging import configure_logging 

7from es_pii_tool.commands.from_yaml import file_based 

8 

9# pylint: disable=W0613,W0622,R0913,R0914 

10# These pylint items are being disabled because of how Click works. 

11 

12 

13@click.group(context_settings=cfg.context_settings()) 

14@cfg.options_from_dict(OPTION_DEFAULTS) 

15@click.version_option(None, "-v", "--version", prog_name="pii-tool") 

16@click.pass_context 

17def run( 

18 ctx, 

19 config, 

20 hosts, 

21 cloud_id, 

22 api_token, 

23 id, 

24 api_key, 

25 username, 

26 password, 

27 bearer_auth, 

28 opaque_id, 

29 request_timeout, 

30 http_compress, 

31 verify_certs, 

32 ca_certs, 

33 client_cert, 

34 client_key, 

35 ssl_assert_hostname, 

36 ssl_assert_fingerprint, 

37 ssl_version, 

38 master_only, 

39 skip_version_test, 

40 loglevel, 

41 logfile, 

42 logformat, 

43 blacklist, 

44): 

45 """Elastic PII Tool""" 

46 ctx.obj["default_config"] = None 

47 cfg.get_config(ctx, quiet=False) 

48 configure_logging(ctx) 

49 cfg.generate_configdict(ctx) 

50 

51 

52@run.command( 

53 context_settings=cfg.context_settings(), 

54 short_help="Show all client configuration options", 

55) 

56@cfg.options_from_dict(SHOW_EVERYTHING) 

57@click.pass_context 

58def show_all_options( 

59 ctx, 

60 config, 

61 hosts, 

62 cloud_id, 

63 api_token, 

64 id, 

65 api_key, 

66 username, 

67 password, 

68 bearer_auth, 

69 opaque_id, 

70 request_timeout, 

71 http_compress, 

72 verify_certs, 

73 ca_certs, 

74 client_cert, 

75 client_key, 

76 ssl_assert_hostname, 

77 ssl_assert_fingerprint, 

78 ssl_version, 

79 master_only, 

80 skip_version_test, 

81 loglevel, 

82 logfile, 

83 logformat, 

84 blacklist, 

85): 

86 """ 

87 ALL OPTIONS SHOWN 

88 

89 The full list of options available for configuring a connection at the command-line. 

90 """ 

91 ctx = click.get_current_context() 

92 click.echo(ctx.get_help()) 

93 ctx.exit() 

94 

95 

96run.add_command(file_based)