helper-cli 0.1.16__py3-none-any.whl → 0.1.21__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
helper/main.py CHANGED
@@ -2,38 +2,50 @@ import click
2
2
  import logging
3
3
  import sys
4
4
  import subprocess
5
- from .commands import internal_ip, public_ip, arch, nixos, docker, speed, system_info
5
+ from . import __version__
6
+ from .commands import (
7
+ internal_ip,
8
+ public_ip,
9
+ arch,
10
+ nixos,
11
+ docker,
12
+ speed,
13
+ system_info,
14
+ venv,
15
+ file,
16
+ )
17
+
6
18
 
7
19
  class VerbosityCommand(click.Command):
8
20
  def parse_args(self, ctx, args):
9
21
  # Initialize verbosity from context if it exists
10
22
  ctx.ensure_object(dict)
11
- verbose = ctx.obj.get('verbosity', 0)
12
-
23
+ verbose = ctx.obj.get("verbosity", 0)
24
+
13
25
  # Process args for verbosity flags
14
26
  new_args = []
15
27
  i = 0
16
28
  while i < len(args):
17
29
  arg = args[i]
18
- if arg == '--verbose':
30
+ if arg == "--verbose":
19
31
  verbose += 1
20
- elif arg.startswith('-v'):
21
- verbose += arg.count('v')
32
+ elif arg.startswith("-v"):
33
+ verbose += arg.count("v")
22
34
  else:
23
35
  new_args.append(arg)
24
36
  i += 1
25
-
37
+
26
38
  # Update verbosity in context
27
- ctx.obj['verbosity'] = verbose
28
-
39
+ ctx.obj["verbosity"] = verbose
40
+
29
41
  # Set up logging
30
42
  self._setup_logging(verbose)
31
-
43
+
32
44
  # Continue with normal argument parsing
33
45
  return super().parse_args(ctx, new_args)
34
-
46
+
35
47
  def _setup_logging(self, verbose):
36
- logger = logging.getLogger('docker-helper')
48
+ logger = logging.getLogger("docker-helper")
37
49
  if verbose >= 3:
38
50
  logger.setLevel(logging.DEBUG)
39
51
  elif verbose == 2:
@@ -43,29 +55,30 @@ class VerbosityCommand(click.Command):
43
55
  else:
44
56
  logger.setLevel(logging.ERROR)
45
57
 
58
+
46
59
  class VerbosityGroup(click.Group):
47
60
  def make_context(self, info_name, args, parent=None, **extra):
48
61
  # Pre-process args to find verbosity flags
49
62
  verbose = 0
50
63
  processed_args = []
51
-
64
+
52
65
  for arg in args:
53
- if arg == '--verbose':
66
+ if arg == "--verbose":
54
67
  verbose += 1
55
- elif arg.startswith('-v'):
56
- verbose += arg.count('v')
68
+ elif arg.startswith("-v"):
69
+ verbose += arg.count("v")
57
70
  else:
58
71
  processed_args.append(arg)
59
-
72
+
60
73
  # Create context with processed args
61
74
  ctx = super().make_context(info_name, processed_args, parent=parent, **extra)
62
-
75
+
63
76
  # Set verbosity in context
64
77
  ctx.ensure_object(dict)
65
- ctx.obj['verbosity'] = verbose
66
-
78
+ ctx.obj["verbosity"] = verbose
79
+
67
80
  # Set up logging
68
- logger = logging.getLogger('docker-helper')
81
+ logger = logging.getLogger("docker-helper")
69
82
  if verbose >= 3:
70
83
  logger.setLevel(logging.DEBUG)
71
84
  elif verbose == 2:
@@ -74,25 +87,33 @@ class VerbosityGroup(click.Group):
74
87
  logger.setLevel(logging.WARNING)
75
88
  else:
76
89
  logger.setLevel(logging.ERROR)
77
-
90
+
78
91
  return ctx
79
92
 
80
- @click.group(cls=VerbosityGroup, context_settings={
81
- 'help_option_names': ['-h', '--help'],
82
- 'token_normalize_func': lambda x: 'helper' if x == 'h' else x
83
- })
93
+
94
+ @click.group(
95
+ cls=VerbosityGroup,
96
+ context_settings={
97
+ "help_option_names": ["-h", "--help"],
98
+ "token_normalize_func": lambda x: "helper" if x == "h" else x,
99
+ },
100
+ )
101
+ @click.version_option(__version__, "-V", "--version", message="%(prog)s version %(version)s")
84
102
  def cli():
85
- """Helper CLI - quick system info
103
+ """Helper CLI - quick system info (v{})
86
104
 
87
105
  You can use 'h' as a shortcut for 'helper' command.
88
106
  Example: h docker ps
89
- """
107
+
108
+ For detailed help on a specific command, use: helper <command> --help
109
+ """.format(__version__)
90
110
  # Set up basic logging
91
111
  logging.basicConfig(
92
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
93
- level=logging.ERROR
112
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
113
+ level=logging.ERROR,
94
114
  )
95
115
 
116
+
96
117
  # Register all commands
97
118
  cli.add_command(internal_ip.internal_ip)
98
119
  cli.add_command(public_ip.public_ip)
@@ -104,6 +125,10 @@ cli.add_command(speed.speed, name="sp")
104
125
  cli.add_command(system_info.system_info, name="system-info")
105
126
  cli.add_command(system_info.system_info, name="sysinfo")
106
127
  cli.add_command(system_info.system_info, name="si")
128
+ cli.add_command(venv.venv, name="v")
129
+ cli.add_command(file.file(), name="file")
130
+ cli.add_command(file.file(), name="f")
131
+
107
132
 
108
133
  @cli.command()
109
134
  @click.pass_context
@@ -116,9 +141,10 @@ def all(ctx):
116
141
  click.echo("\n=== Architecture ===")
117
142
  ctx.invoke(arch.arch)
118
143
  click.echo("\n=== NixOS ===")
119
- ctx.invoke(nixos.nixos, 'version')
144
+ ctx.invoke(nixos.nixos, "version")
120
145
  click.echo("\n=== System Info ===")
121
146
  ctx.invoke(system_info.system_info)
122
147
 
148
+
123
149
  if __name__ == "__main__":
124
150
  cli()
helper/table.py ADDED
@@ -0,0 +1,29 @@
1
+ import click
2
+ import json
3
+ import yaml
4
+ from tabulate import tabulate
5
+
6
+ data = [{"name": "Huy", "age": 23}, {"name": "An", "age": 25}]
7
+
8
+
9
+ @click.command()
10
+ @click.option(
11
+ "--format",
12
+ "-f",
13
+ type=click.Choice(["json", "yaml", "table", "text"]),
14
+ default="table",
15
+ )
16
+ def show(format):
17
+ if format == "json":
18
+ click.echo(json.dumps(data, indent=2))
19
+ elif format == "yaml":
20
+ click.echo(yaml.dump(data))
21
+ elif format == "table":
22
+ click.echo(tabulate(data, headers="keys"))
23
+ else:
24
+ for item in data:
25
+ click.echo(f"{item['name']} - {item['age']}")
26
+
27
+
28
+ if __name__ == "__main__":
29
+ show()
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: helper-cli
3
- Version: 0.1.16
3
+ Version: 0.1.21
4
4
  Summary: Simple system info CLI
5
5
  Author-email: Huy Nguyen <huy.ntq02@gmail.com>
6
- License: MIT
6
+ License-Expression: GPL-3.0-or-later
7
7
  Classifier: Development Status :: 4 - Beta
8
8
  Classifier: Intended Audience :: Developers
9
9
  Classifier: Programming Language :: Python :: 3
@@ -0,0 +1,19 @@
1
+ helper/__init__.py,sha256=PEIHNVQJi4gfYU7emp8tDETLEHmk_0TfYcTZBj8d3mI,218
2
+ helper/main.py,sha256=P0XTHfjk7RpuPLjn3J3VwDIeE046DmMlKCEy2ePBCEw,4191
3
+ helper/table.py,sha256=xgB0kv4MiGq-Q5keMiJTANGzKEoiiOn2btq8PLimW7Q,638
4
+ helper/utils.py,sha256=JynYacwFA9kgkDuWpGPCj3VxYl_yFJL-FRCKlW1g6Mo,337
5
+ helper/commands/__init__.py,sha256=HFk0MU1U4VqGJUkb9SvCoslqpYSah8KePP9tP8Xzzs4,30
6
+ helper/commands/arch.py,sha256=Gry_K5W4QJHWZuWdk7P20aHj0-Tn_huJvVi08rG7BcI,304
7
+ helper/commands/docker.py,sha256=sciuxKJ8-6RtI_gAxq_7rvVtDrRapiEzkEBb_rIC4uk,27661
8
+ helper/commands/file.py,sha256=xDjZw4ypqKLUZTVpkBrHYS-4XkRLl1Vv6YQMEiAPYSM,5607
9
+ helper/commands/internal_ip.py,sha256=BfKjTIT1TO_RnDPHZOsjxprL4yUsO9ywAel3MJaLZXo,1066
10
+ helper/commands/nixos.py,sha256=4p7He9L_ZJyTHuhb8voDrJlnL8m0RhiDSnW0JG6rUvk,3396
11
+ helper/commands/public_ip.py,sha256=wvfYC4OpiBjBaqYBBgbN60jqm4AdMO9CY0qccN_eEwM,428
12
+ helper/commands/speed.py,sha256=Ar6qkw0uRg25tmm3BKwo_HixDkl0y_heLYYC89Jx96I,963
13
+ helper/commands/system_info.py,sha256=L7FvykhL4PQSET3xb7rjJ4EdAQCnzUmLacZ7Dtm7feU,11205
14
+ helper/commands/venv.py,sha256=beIoGSS6VmTthrJh2ud0RYVSGDVHRw9W5l9xbOL6Hks,4139
15
+ helper_cli-0.1.21.dist-info/METADATA,sha256=8tZLetU_Izz5CD2On2Vq_hjgP7xwRVNfuAbTN6LGT2k,1643
16
+ helper_cli-0.1.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
+ helper_cli-0.1.21.dist-info/entry_points.txt,sha256=SeXS_UhbMNq2biiMGgbcJcJfqkhTIDmQ4UID3ZZgj0c,63
18
+ helper_cli-0.1.21.dist-info/top_level.txt,sha256=VM8lkErPJijbKhnfEGA_hE_YDXde4iizgqWKloZIxW8,7
19
+ helper_cli-0.1.21.dist-info/RECORD,,
@@ -1,15 +0,0 @@
1
- helper/main.py,sha256=iLoQRR_nTgb9Uv_GqebSQPJluvo7PRwBuXGCD3T5JIs,3840
2
- helper/utils.py,sha256=JynYacwFA9kgkDuWpGPCj3VxYl_yFJL-FRCKlW1g6Mo,337
3
- helper/commands/__init__.py,sha256=HFk0MU1U4VqGJUkb9SvCoslqpYSah8KePP9tP8Xzzs4,30
4
- helper/commands/arch.py,sha256=AREsblUki99P_wVpi44maQd7KA8IlUCJ6ilzJAQODDU,141
5
- helper/commands/docker.py,sha256=ktO6v5vEb8glhEZQl5ijMsQ4Kl6UL_FONNK4iCOvwgg,25250
6
- helper/commands/internal_ip.py,sha256=ZN7c1HRgB5f-wRk9IwfGQeI3YuZqmPW-UflIpGEImt0,786
7
- helper/commands/nixos.py,sha256=--Uz2lA-xw6-spp1WBjzzfu4-imFtcziyZuUHZk3Pxs,3113
8
- helper/commands/public_ip.py,sha256=HS99RDYCaKDZ-AxMQhUwazgR-tT6IGlBb5Qn0f5ITPg,150
9
- helper/commands/speed.py,sha256=AZ6RoPSi3Al4Z1RsMDIm9pjxYxXXs01qn6Fr7TEW8SM,974
10
- helper/commands/system_info.py,sha256=QknKrFlknpvAWjHkOoKJkIMQp0S6FT_wecxHgx7Unqs,10716
11
- helper_cli-0.1.16.dist-info/METADATA,sha256=oY4-b2_Z8Jmgzu0TgUEVFeIt0DsusNdCnCbWYc9LAZg,1619
12
- helper_cli-0.1.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- helper_cli-0.1.16.dist-info/entry_points.txt,sha256=SeXS_UhbMNq2biiMGgbcJcJfqkhTIDmQ4UID3ZZgj0c,63
14
- helper_cli-0.1.16.dist-info/top_level.txt,sha256=VM8lkErPJijbKhnfEGA_hE_YDXde4iizgqWKloZIxW8,7
15
- helper_cli-0.1.16.dist-info/RECORD,,