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

24 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2025-03-18 12:25 -0600

1"""Command-line interface""" 

2 

3import logging 

4import click 

5from es_client.defaults import OPTION_DEFAULTS, SHOW_EVERYTHING 

6from es_client.helpers import config as cfg 

7from es_client.helpers.logging import configure_logging 

8from es_pii_tool.commands.from_yaml import file_based 

9 

10# pylint: disable=W0613,W0622,R0913,R0914,R0917 

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

12 

13logger = logging.getLogger(__name__) 

14 

15 

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

17@cfg.options_from_dict(OPTION_DEFAULTS) 

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

19@click.pass_context 

20def run( 

21 ctx, 

22 config, 

23 hosts, 

24 cloud_id, 

25 api_token, 

26 id, 

27 api_key, 

28 username, 

29 password, 

30 bearer_auth, 

31 opaque_id, 

32 request_timeout, 

33 http_compress, 

34 verify_certs, 

35 ca_certs, 

36 client_cert, 

37 client_key, 

38 ssl_assert_hostname, 

39 ssl_assert_fingerprint, 

40 ssl_version, 

41 master_only, 

42 skip_version_test, 

43 loglevel, 

44 logfile, 

45 logformat, 

46 blacklist, 

47): 

48 """Elastic PII Tool""" 

49 ctx.obj["default_config"] = None 

50 cfg.get_config(ctx, quiet=False) 

51 configure_logging(ctx) 

52 cfg.generate_configdict(ctx) 

53 

54 

55@run.command( 

56 context_settings=cfg.context_settings(), 

57 short_help="Show all client configuration options", 

58) 

59@cfg.options_from_dict(SHOW_EVERYTHING) 

60@click.pass_context 

61def show_all_options( 

62 ctx, 

63 config, 

64 hosts, 

65 cloud_id, 

66 api_token, 

67 id, 

68 api_key, 

69 username, 

70 password, 

71 bearer_auth, 

72 opaque_id, 

73 request_timeout, 

74 http_compress, 

75 verify_certs, 

76 ca_certs, 

77 client_cert, 

78 client_key, 

79 ssl_assert_hostname, 

80 ssl_assert_fingerprint, 

81 ssl_version, 

82 master_only, 

83 skip_version_test, 

84 loglevel, 

85 logfile, 

86 logformat, 

87 blacklist, 

88): 

89 """ 

90 ALL OPTIONS SHOWN 

91 

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

93 """ 

94 ctx = click.get_current_context() 

95 click.echo(ctx.get_help()) 

96 ctx.exit() 

97 

98 

99run.add_command(file_based)