linux-commands-guide 2.0.0__tar.gz → 2.0.1__tar.gz

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.
Files changed (67) hide show
  1. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/PKG-INFO +1 -1
  2. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/__init__.py +1 -1
  3. linux_commands_guide-2.0.1/guia_linux/cli.py +129 -0
  4. linux_commands_guide-2.0.1/guia_linux/utils.py +97 -0
  5. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/linux_commands_guide.egg-info/PKG-INFO +1 -1
  6. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/pyproject.toml +1 -1
  7. linux_commands_guide-2.0.0/guia_linux/cli.py +0 -89
  8. linux_commands_guide-2.0.0/guia_linux/utils.py +0 -59
  9. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/README.md +0 -0
  10. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/__init__.py +0 -0
  11. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/awk.py +0 -0
  12. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/cat.py +0 -0
  13. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/chmod.py +0 -0
  14. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/chown.py +0 -0
  15. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/crontab.py +0 -0
  16. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/curl.py +0 -0
  17. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/cut.py +0 -0
  18. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/df.py +0 -0
  19. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/docker.py +0 -0
  20. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/du.py +0 -0
  21. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/file_descriptors.py +0 -0
  22. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/find.py +0 -0
  23. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/firewall_cmd.py +0 -0
  24. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/free.py +0 -0
  25. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/git.py +0 -0
  26. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/grep.py +0 -0
  27. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/head.py +0 -0
  28. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/htop.py +0 -0
  29. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/ifconfig.py +0 -0
  30. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/ip.py +0 -0
  31. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/iptables.py +0 -0
  32. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/jq.py +0 -0
  33. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/logs.py +0 -0
  34. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/lsblk.py +0 -0
  35. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/lsof.py +0 -0
  36. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/lxc.py +0 -0
  37. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/nc.py +0 -0
  38. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/netstat.py +0 -0
  39. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/nmap.py +0 -0
  40. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/ps.py +0 -0
  41. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/regex.py +0 -0
  42. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/rsync.py +0 -0
  43. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/scp.py +0 -0
  44. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/sed.py +0 -0
  45. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/shortcuts.py +0 -0
  46. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/sort.py +0 -0
  47. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/ss.py +0 -0
  48. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/ssh.py +0 -0
  49. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/system.py +0 -0
  50. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/systemctl.py +0 -0
  51. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/tail.py +0 -0
  52. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/tar.py +0 -0
  53. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/tee.py +0 -0
  54. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/tmux.py +0 -0
  55. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/top.py +0 -0
  56. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/tr.py +0 -0
  57. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/uname.py +0 -0
  58. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/uniq.py +0 -0
  59. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/vim.py +0 -0
  60. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/watch.py +0 -0
  61. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/guia_linux/tools/xargs.py +0 -0
  62. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/linux_commands_guide.egg-info/SOURCES.txt +0 -0
  63. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/linux_commands_guide.egg-info/dependency_links.txt +0 -0
  64. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/linux_commands_guide.egg-info/entry_points.txt +0 -0
  65. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/linux_commands_guide.egg-info/requires.txt +0 -0
  66. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/linux_commands_guide.egg-info/top_level.txt +0 -0
  67. {linux_commands_guide-2.0.0 → linux_commands_guide-2.0.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: linux-commands-guide
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: Bilingual ES/EN interactive Linux command reference — 50+ tools with keyword search
5
5
  Author-email: Serber1990 <serber1990@pm.me>
6
6
  License-Expression: MIT
@@ -1,4 +1,4 @@
1
1
  from guia_linux.cli import main
2
2
 
3
- __version__ = "2.0.0"
3
+ __version__ = "2.0.1"
4
4
  __all__ = ["main"]
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env python3
2
+ import argparse
3
+ import sys
4
+ from shellcolorize import Color
5
+ from guia_linux.tools import TOOLS
6
+ from guia_linux.utils import search_all, strip_ansi
7
+
8
+
9
+ def _help_header(lang: str) -> None:
10
+ title = 'Linux Command Reference' if lang == 'en' else 'Guía de Comandos Linux'
11
+ w = max(46, len(title) + 6)
12
+ border = '═' * w
13
+ print()
14
+ print(f" {Color.CYAN}╔{border}╗{Color.RESET}")
15
+ print(f" {Color.CYAN}║{Color.RESET} {Color.BOLD}{Color.CYAN}{title}{Color.RESET}"
16
+ + ' ' * max(0, w - len(title) - 2)
17
+ + f" {Color.CYAN}║{Color.RESET}")
18
+ print(f" {Color.CYAN}╚{border}╝{Color.RESET}")
19
+
20
+
21
+ def _print_help(lang: str) -> None:
22
+ _help_header(lang)
23
+
24
+ if lang == 'en':
25
+ print(f"""
26
+ {Color.BOLD}Usage{Color.RESET}
27
+ {Color.GREEN}lh{Color.RESET} <tool> Show commands for a tool
28
+ {Color.GREEN}lh{Color.RESET} <tool> --lang en Force English output
29
+ {Color.GREEN}lh{Color.RESET} -s <keyword> Search across all tools
30
+ {Color.GREEN}lh{Color.RESET} -s <keyword> --lang en Search with English descriptions
31
+
32
+ {Color.BOLD}Examples{Color.RESET}
33
+ {Color.GREEN}lh grep{Color.RESET} All grep options
34
+ {Color.GREEN}lh --lang en docker{Color.RESET} Docker commands in English
35
+ {Color.GREEN}lh -s recursive{Color.RESET} Find every command mentioning "recursive"
36
+ """)
37
+ else:
38
+ print(f"""
39
+ {Color.BOLD}Uso{Color.RESET}
40
+ {Color.GREEN}lh{Color.RESET} <herramienta> Muestra comandos de una herramienta
41
+ {Color.GREEN}lh{Color.RESET} <herramienta> --lang es Fuerza salida en español
42
+ {Color.GREEN}lh{Color.RESET} -s <término> Busca en todas las herramientas
43
+ {Color.GREEN}lh{Color.RESET} -s <término> --lang en Busca con descripciones en inglés
44
+
45
+ {Color.BOLD}Ejemplos{Color.RESET}
46
+ {Color.GREEN}lh grep{Color.RESET} Todas las opciones de grep
47
+ {Color.GREEN}lh --lang en docker{Color.RESET} Comandos docker en inglés
48
+ {Color.GREEN}lh -s recursivo{Color.RESET} Busca comandos con "recursivo"
49
+ """)
50
+
51
+ label = 'Tool' if lang == 'en' else 'Herramienta'
52
+ desc = 'Description' if lang == 'en' else 'Descripción'
53
+ print(f" {Color.BOLD}{Color.GREEN}{label:<18}{desc}{Color.RESET}")
54
+ print(f" {Color.DIM}{'─' * 60}{Color.RESET}")
55
+ for name, module in sorted(TOOLS.items()):
56
+ brief = getattr(module, 'BRIEF_EN' if lang == 'en' else 'BRIEF', '')
57
+ print(f" {Color.GREEN}{name:<18}{Color.RESET}{Color.DIM}{brief}{Color.RESET}")
58
+ print()
59
+
60
+
61
+ def _search(query: str, lang: str) -> None:
62
+ results = search_all(query, TOOLS, lang)
63
+ desc_key = 'description_en' if lang == 'en' else 'description'
64
+
65
+ w = 50
66
+ border = '═' * w
67
+ header = f"Search: {query}" if lang == 'en' else f"Búsqueda: {query}"
68
+ count = f'{len(results)} result{"s" if len(results) != 1 else ""}' if lang == 'en' \
69
+ else f'{len(results)} resultado{"s" if len(results) != 1 else ""}'
70
+
71
+ print()
72
+ print(f" {Color.CYAN}╔{border}╗{Color.RESET}")
73
+ print(f" {Color.CYAN}║{Color.RESET} {Color.BOLD}{Color.CYAN}{header}{Color.RESET}"
74
+ + ' ' * max(0, w - len(header) - 2)
75
+ + f" {Color.CYAN}║{Color.RESET}")
76
+ print(f" {Color.CYAN}╚{border}╝{Color.RESET}")
77
+
78
+ if not results:
79
+ msg = f"No results for '{query}'" if lang == 'en' else f"Sin resultados para '{query}'"
80
+ print(f"\n {Color.DIM}{msg}{Color.RESET}\n")
81
+ return
82
+
83
+ print(f"\n {Color.DIM}{count}{Color.RESET}\n")
84
+
85
+ current_tool = None
86
+ for tool_name, entry in results:
87
+ if tool_name != current_tool:
88
+ print(f" {Color.CYAN}▶ {Color.BOLD}{tool_name}{Color.RESET}")
89
+ current_tool = tool_name
90
+ display = strip_ansi(str(
91
+ entry.get('command') or entry.get('logfile') or entry.get('pattern') or ''
92
+ ))
93
+ desc = entry.get(desc_key, '')
94
+ print(f" {Color.GREEN}{display}{Color.RESET}")
95
+ print(f" {Color.DIM}{desc}{Color.RESET}")
96
+ print()
97
+
98
+
99
+ def main() -> None:
100
+ parser = argparse.ArgumentParser(add_help=False)
101
+ parser.add_argument('tool', nargs='?', default=None)
102
+ parser.add_argument('-s', '--search', metavar='KEYWORD', default=None)
103
+ parser.add_argument('--lang', choices=['es', 'en'], default='es')
104
+ parser.add_argument('-h', '--help', action='store_true')
105
+ args = parser.parse_args()
106
+
107
+ lang = args.lang
108
+
109
+ if args.help or (args.tool is None and args.search is None):
110
+ _print_help(lang)
111
+ return
112
+
113
+ if args.search:
114
+ _search(args.search, lang)
115
+ return
116
+
117
+ key = args.tool.lower()
118
+ if key not in TOOLS:
119
+ msg = (f"Tool '{args.tool}' not found — run 'lh --help' for the full list."
120
+ if lang == 'en'
121
+ else f"Herramienta '{args.tool}' no encontrada — ejecuta 'lh --help' para ver la lista.")
122
+ print(f"\n {Color.RED}✖ {msg}{Color.RESET}\n")
123
+ sys.exit(1)
124
+
125
+ TOOLS[key].show(lang)
126
+
127
+
128
+ if __name__ == '__main__':
129
+ main()
@@ -0,0 +1,97 @@
1
+ import re
2
+ from shellcolorize import Color
3
+
4
+ _ANSI = re.compile(r'\033\[[0-9;]*m')
5
+
6
+
7
+ def strip_ansi(text: str) -> str:
8
+ return _ANSI.sub('', text)
9
+
10
+
11
+ def ansi_ljust(text: str, width: int) -> str:
12
+ """Pad text to visible width, ignoring ANSI escape codes."""
13
+ visible = len(strip_ansi(text))
14
+ return text + ' ' * max(0, width - visible)
15
+
16
+
17
+ # ── Shared visual primitives ──────────────────────────────────────────────────
18
+
19
+ def _header(title: str) -> None:
20
+ w = max(46, len(title) + 6)
21
+ border = '═' * w
22
+ print()
23
+ print(f" {Color.CYAN}╔{border}╗{Color.RESET}")
24
+ print(f" {Color.CYAN}║{Color.RESET} {Color.BOLD}{Color.CYAN}{title}{Color.RESET}"
25
+ + ' ' * max(0, w - len(title) - 2)
26
+ + f" {Color.CYAN}║{Color.RESET}")
27
+ print(f" {Color.CYAN}╚{border}╝{Color.RESET}")
28
+ print()
29
+
30
+
31
+ def _column_headers(cmd_label: str, desc_label: str, cmd_width: int = 50) -> None:
32
+ print(f" {Color.BOLD}{Color.GREEN}{cmd_label:<{cmd_width}}{Color.RESET}"
33
+ f" {Color.BOLD}{Color.GREEN}{desc_label}{Color.RESET}")
34
+ print(f" {Color.DIM}{'─' * (cmd_width + 2 + 42)}{Color.RESET}")
35
+
36
+
37
+ def _section(text: str) -> None:
38
+ print()
39
+ print(f" {Color.CYAN}▶ {Color.BOLD}{text}{Color.RESET}")
40
+ print(f" {Color.DIM}{'─' * 94}{Color.RESET}")
41
+
42
+
43
+ # ── Main table printer ────────────────────────────────────────────────────────
44
+
45
+ def print_table(title: str, commands: list, lang: str = 'es') -> None:
46
+ desc_key = 'description_en' if lang == 'en' else 'description'
47
+ cmd_label = 'Command' if lang == 'en' else 'Comando'
48
+ desc_label = 'Description' if lang == 'en' else 'Descripción'
49
+ CMD_WIDTH = 50
50
+
51
+ _header(title)
52
+ has_sections = any('section' in e or 'category' in e for e in commands)
53
+
54
+ if not has_sections:
55
+ _column_headers(cmd_label, desc_label, CMD_WIDTH)
56
+
57
+ for entry in commands:
58
+ # ── Section / category header ──────────────────────────────────────
59
+ if 'section' in entry or 'category' in entry:
60
+ key = 'section' if 'section' in entry else 'category'
61
+ text = entry.get(f'{key}_en' if lang == 'en' else key, entry.get(key, ''))
62
+ if text:
63
+ if not any(e for e in commands[:commands.index(entry)]
64
+ if 'section' in e or 'category' in e):
65
+ _column_headers(cmd_label, desc_label, CMD_WIDTH)
66
+ _section(strip_ansi(str(text)))
67
+ continue
68
+
69
+ display = entry.get('command') or entry.get('logfile') or entry.get('pattern') or ''
70
+ desc = entry.get(desc_key, '')
71
+
72
+ if display or desc:
73
+ padded = ansi_ljust(str(display), CMD_WIDTH)
74
+ print(f" {padded} {Color.DIM}{desc}{Color.RESET}")
75
+
76
+ print()
77
+
78
+
79
+ # ── Cross-tool search ─────────────────────────────────────────────────────────
80
+
81
+ def search_all(query: str, tools: dict, lang: str = 'es') -> list:
82
+ desc_key = 'description_en' if lang == 'en' else 'description'
83
+ results = []
84
+ q = query.lower()
85
+ for tool_name, module in tools.items():
86
+ for entry in getattr(module, 'COMMANDS', []):
87
+ if 'section' in entry or 'category' in entry:
88
+ continue
89
+ display = strip_ansi(str(
90
+ entry.get('command') or
91
+ entry.get('logfile') or
92
+ entry.get('pattern') or ''
93
+ ))
94
+ desc = entry.get(desc_key, '')
95
+ if q in display.lower() or q in desc.lower():
96
+ results.append((tool_name, entry))
97
+ return results
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: linux-commands-guide
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: Bilingual ES/EN interactive Linux command reference — 50+ tools with keyword search
5
5
  Author-email: Serber1990 <serber1990@pm.me>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "linux-commands-guide"
7
- version = "2.0.0"
7
+ version = "2.0.1"
8
8
  description = "Bilingual ES/EN interactive Linux command reference — 50+ tools with keyword search"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env python3
2
- import argparse
3
- import sys
4
- from shellcolorize import Color
5
- from guia_linux.tools import TOOLS
6
- from guia_linux.utils import search_all, strip_ansi
7
-
8
-
9
- def _print_help(lang: str) -> None:
10
- if lang == "en":
11
- print(f"\n{Color.CYAN}{Color.BOLD}Linux Command Reference{Color.RESET} — usage:\n")
12
- print(f" {Color.GREEN}lh{Color.RESET} <tool> Show commands for a tool")
13
- print(f" {Color.GREEN}lh{Color.RESET} -s <keyword> Search across all tools")
14
- print(f" {Color.GREEN}lh{Color.RESET} --lang en <tool> Force English output")
15
- print(f" {Color.GREEN}lh{Color.RESET} --lang es <tool> Force Spanish output\n")
16
- else:
17
- print(f"\n{Color.CYAN}{Color.BOLD}Guía de Comandos Linux{Color.RESET} — uso:\n")
18
- print(f" {Color.GREEN}lh{Color.RESET} <herramienta> Muestra comandos de una herramienta")
19
- print(f" {Color.GREEN}lh{Color.RESET} -s <término> Busca en todas las herramientas")
20
- print(f" {Color.GREEN}lh{Color.RESET} --lang en <tool> Fuerza salida en inglés")
21
- print(f" {Color.GREEN}lh{Color.RESET} --lang es <tool> Fuerza salida en español\n")
22
-
23
- label_tool = "Tool" if lang == "en" else "Herramienta"
24
- label_desc = "Description" if lang == "en" else "Descripción"
25
- print(f" {Color.YELLOW}{label_tool:<16}{label_desc}{Color.RESET}")
26
- print(f" {'-' * 60}")
27
- for name, module in sorted(TOOLS.items()):
28
- desc = getattr(module, 'TITLE_EN' if lang == 'en' else 'TITLE', name.upper())
29
- brief = getattr(module, 'BRIEF_EN' if lang == 'en' else 'BRIEF', '')
30
- print(f" {Color.GREEN}{name:<16}{Color.RESET}{brief}")
31
- print()
32
-
33
-
34
- def _search(query: str, lang: str) -> None:
35
- results = search_all(query, TOOLS, lang)
36
- desc_key = "description_en" if lang == "en" else "description"
37
- if not results:
38
- msg = f"No results for '{query}'" if lang == "en" else f"Sin resultados para '{query}'"
39
- print(f"\n{Color.RED}{msg}{Color.RESET}\n")
40
- return
41
-
42
- header = f"Results for '{query}'" if lang == "en" else f"Resultados para '{query}'"
43
- print(f"\n{Color.CYAN}{Color.BOLD}{header}{Color.RESET} ({len(results)}):\n")
44
- current_tool = None
45
- for tool_name, entry in results:
46
- if tool_name != current_tool:
47
- print(f"\n {Color.YELLOW}[{tool_name}]{Color.RESET}")
48
- current_tool = tool_name
49
- display = str(entry.get("command") or entry.get("logfile") or entry.get("pattern") or "")
50
- desc = entry.get(desc_key, "")
51
- clean = strip_ansi(display)
52
- print(f" {Color.GREEN}{clean}{Color.RESET}")
53
- print(f" {Color.RED}{desc}{Color.RESET}")
54
- print()
55
-
56
-
57
- def main() -> None:
58
- parser = argparse.ArgumentParser(add_help=False)
59
- parser.add_argument("tool", nargs="?", default=None)
60
- parser.add_argument("-s", "--search", metavar="KEYWORD", default=None)
61
- parser.add_argument("--lang", choices=["es", "en"], default="es")
62
- parser.add_argument("-h", "--help", action="store_true")
63
- args = parser.parse_args()
64
-
65
- lang = args.lang
66
-
67
- if args.help or (args.tool is None and args.search is None):
68
- _print_help(lang)
69
- return
70
-
71
- if args.search:
72
- _search(args.search, lang)
73
- return
74
-
75
- tool_key = args.tool.lower()
76
- if tool_key not in TOOLS:
77
- msg = (
78
- f"Tool '{args.tool}' not found. Run 'lh --help' for the full list."
79
- if lang == "en"
80
- else f"Herramienta '{args.tool}' no encontrada. Ejecuta 'lh --help' para ver la lista."
81
- )
82
- print(f"\n{Color.RED}{msg}{Color.RESET}\n")
83
- sys.exit(1)
84
-
85
- TOOLS[tool_key].show(lang)
86
-
87
-
88
- if __name__ == "__main__":
89
- main()
@@ -1,59 +0,0 @@
1
- import re
2
- from shellcolorize import Color
3
-
4
- _ANSI_RE = re.compile(r'\033\[[0-9;]*m')
5
-
6
-
7
- def strip_ansi(text: str) -> str:
8
- return _ANSI_RE.sub('', text)
9
-
10
-
11
- def ansi_ljust(text: str, width: int) -> str:
12
- visible = len(strip_ansi(text))
13
- return text + ' ' * max(0, width - visible)
14
-
15
-
16
- def print_table(title: str, commands: list, lang: str = "es") -> None:
17
- desc_key = "description_en" if lang == "en" else "description"
18
- cmd_label = "Command" if lang == "en" else "Comando"
19
- desc_label = "Description" if lang == "en" else "Descripción"
20
- sep = "-" * 132
21
-
22
- print(f"\n{Color.CYAN}{Color.BOLD}{title}{Color.RESET}:\n")
23
- print(f"{cmd_label:<50} | {desc_label}")
24
- print(sep)
25
-
26
- for entry in commands:
27
- # Section / category headers
28
- if "section" in entry or "category" in entry:
29
- key = "section" if "section" in entry else "category"
30
- text = entry.get(f"{key}_en" if lang == "en" else key, entry.get(key, ""))
31
- if text:
32
- print(f"\n{Color.CYAN}{strip_ansi(str(text))}{Color.RESET}")
33
- print(sep)
34
- continue
35
-
36
- display = entry.get("command") or entry.get("logfile") or entry.get("pattern") or ""
37
- desc = entry.get(desc_key, "")
38
-
39
- if display or desc:
40
- print(f"{ansi_ljust(str(display), 59)} | {Color.RED}{desc}{Color.RESET}")
41
-
42
-
43
- def search_all(query: str, tools: dict, lang: str = "es") -> list:
44
- desc_key = "description_en" if lang == "en" else "description"
45
- results = []
46
- q = query.lower()
47
- for tool_name, module in tools.items():
48
- for entry in getattr(module, 'COMMANDS', []):
49
- if "section" in entry or "category" in entry:
50
- continue
51
- display = strip_ansi(str(
52
- entry.get("command") or
53
- entry.get("logfile") or
54
- entry.get("pattern") or ""
55
- ))
56
- desc = entry.get(desc_key, "")
57
- if q in display.lower() or q in desc.lower():
58
- results.append((tool_name, entry))
59
- return results