cmdex 0.1.0__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.
cmdex-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: cmdex
3
+ Version: 0.1.0
4
+ Summary: Cmdex: Terminal command explainer for developers
5
+ Author: Deepak Kumar Das
6
+ Requires-Dist: click
7
+ Requires-Dist: rich
@@ -0,0 +1,29 @@
1
+ import click
2
+ from cmdex.explainer import explain_command
3
+ from rich import print
4
+ from importlib.metadata import version, PackageNotFoundError
5
+
6
+ def get_version():
7
+ try:
8
+ return version("cmdex")
9
+ except PackageNotFoundError:
10
+ return "0.0.0" # fallback if not installed
11
+
12
+ @click.group()
13
+ @click.version_option(version=get_version(), prog_name="cmdex")
14
+ def cli():
15
+ """Cmdex: Your Terminal Command Explainer"""
16
+ pass
17
+
18
+ @cli.command(name="explain")
19
+ @click.argument("command_string")
20
+ def explain_cmd(command_string):
21
+ panel = explain_command(command_string)
22
+ print(panel)
23
+
24
+ # aliases
25
+ cli.add_command(explain_cmd, name="why")
26
+ cli.add_command(explain_cmd, name="xplain")
27
+
28
+ if __name__ == "__main__":
29
+ cli()
@@ -0,0 +1,50 @@
1
+ # cmdex/explainer.py
2
+ import json
3
+ from rich import print
4
+ from rich.panel import Panel
5
+
6
+ def load_db():
7
+ with open("cmdex/db.json") as f:
8
+ return json.load(f)
9
+
10
+ def explain_command(cmd):
11
+ db = load_db()
12
+ parts = cmd.strip().split()
13
+
14
+ if not parts:
15
+ return "[red]No command provided[/red]"
16
+
17
+ command = parts[0]
18
+ flags = [p for p in parts if p.startswith("-")]
19
+ args = [p for p in parts[1:] if not p.startswith("-")]
20
+
21
+ output = []
22
+
23
+ # Explain command
24
+ if command in db["commands"]:
25
+ output.append(f"[cyan]{command}[/cyan] → {db['commands'][command]}")
26
+ else:
27
+ output.append(f"[red]{command}[/red] → Unknown command")
28
+
29
+ # Explain flags
30
+ for flag in flags:
31
+ meaning = db["flags"].get(flag, "Unknown flag")
32
+ output.append(f"[yellow]{flag}[/yellow] → {meaning}")
33
+
34
+ # Show arguments
35
+ if args:
36
+ output.append(f"[green]Arguments[/green] → {' '.join(args)}")
37
+
38
+ # Danger detection
39
+ danger_msg = db.get("dangerous", {}).get(cmd)
40
+ if danger_msg:
41
+ output.append(f"\n[bold red]🚨 DANGER: {danger_msg}[/bold red]")
42
+ output.append("💡 Safer alternative: Think twice before running!")
43
+
44
+ # Special checks for known risky patterns
45
+ if command == "rm" and "-rf" in cmd:
46
+ output.append("[bold red]⚠ WARNING: Force delete detected[/bold red]")
47
+ if "chmod 777" in cmd:
48
+ output.append("[bold red]⚠ WARNING: Full permissions granted[/bold red]")
49
+
50
+ return Panel("\n".join(output), title="Cmdex Explanation", expand=False)
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: cmdex
3
+ Version: 0.1.0
4
+ Summary: Cmdex: Terminal command explainer for developers
5
+ Author: Deepak Kumar Das
6
+ Requires-Dist: click
7
+ Requires-Dist: rich
@@ -0,0 +1,9 @@
1
+ pyproject.toml
2
+ cmdex/cli.py
3
+ cmdex/explainer.py
4
+ cmdex.egg-info/PKG-INFO
5
+ cmdex.egg-info/SOURCES.txt
6
+ cmdex.egg-info/dependency_links.txt
7
+ cmdex.egg-info/entry_points.txt
8
+ cmdex.egg-info/requires.txt
9
+ cmdex.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cmdex = cmdex.cli:cli
@@ -0,0 +1,2 @@
1
+ click
2
+ rich
@@ -0,0 +1 @@
1
+ cmdex
@@ -0,0 +1,13 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "cmdex"
7
+ version = "0.1.0"
8
+ description = "Cmdex: Terminal command explainer for developers"
9
+ authors = [{name="Deepak Kumar Das"}]
10
+ dependencies = ["click", "rich"]
11
+
12
+ [project.scripts]
13
+ cmdex = "cmdex.cli:cli"
cmdex-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+