cheat-cli 0.1.0__tar.gz → 0.1.2__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.
- cheat_cli-0.1.2/MANIFEST.in +1 -0
- {cheat_cli-0.1.0 → cheat_cli-0.1.2}/PKG-INFO +3 -5
- {cheat_cli-0.1.0 → cheat_cli-0.1.2}/cheat_cli/cli.py +69 -13
- cheat_cli-0.1.2/cheat_cli/data/commands.csv +2 -0
- {cheat_cli-0.1.0 → cheat_cli-0.1.2}/cheat_cli.egg-info/PKG-INFO +3 -5
- {cheat_cli-0.1.0 → cheat_cli-0.1.2}/cheat_cli.egg-info/SOURCES.txt +3 -1
- cheat_cli-0.1.2/pyproject.toml +20 -0
- cheat_cli-0.1.0/pyproject.toml +0 -25
- {cheat_cli-0.1.0 → cheat_cli-0.1.2}/LICENSE +0 -0
- {cheat_cli-0.1.0 → cheat_cli-0.1.2}/README.md +0 -0
- {cheat_cli-0.1.0 → cheat_cli-0.1.2}/cheat_cli/__init__.py +0 -0
- {cheat_cli-0.1.0 → cheat_cli-0.1.2}/cheat_cli.egg-info/dependency_links.txt +0 -0
- {cheat_cli-0.1.0 → cheat_cli-0.1.2}/cheat_cli.egg-info/entry_points.txt +0 -0
- {cheat_cli-0.1.0 → cheat_cli-0.1.2}/cheat_cli.egg-info/requires.txt +0 -0
- {cheat_cli-0.1.0 → cheat_cli-0.1.2}/cheat_cli.egg-info/top_level.txt +0 -0
- {cheat_cli-0.1.0 → cheat_cli-0.1.2}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include cheat_cli/data *.csv
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cheat-cli
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: A terminal-first cheat sheet
|
|
5
|
-
Author
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: A terminal-first personal cheat sheet for Linux developers
|
|
5
|
+
Author: Rejish
|
|
6
6
|
License: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/RejishJ/cheat-cli
|
|
8
|
-
Project-URL: Repository, https://github.com/RejishJ/cheat-cli
|
|
9
7
|
Requires-Python: >=3.8
|
|
10
8
|
Description-Content-Type: text/markdown
|
|
11
9
|
License-File: LICENSE
|
|
@@ -1,30 +1,69 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
|
|
3
3
|
import sys
|
|
4
|
+
import shutil
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
4
7
|
import pandas as pd
|
|
5
8
|
from tabulate import tabulate
|
|
6
9
|
from importlib.resources import files
|
|
7
10
|
|
|
8
|
-
#
|
|
11
|
+
# ===============================
|
|
12
|
+
# Paths & Data Handling
|
|
13
|
+
# ===============================
|
|
14
|
+
|
|
15
|
+
def user_data_path() -> Path:
|
|
16
|
+
"""
|
|
17
|
+
Location for user-modifiable data.
|
|
18
|
+
"""
|
|
19
|
+
return Path.home() / ".local" / "share" / "cheat-cli" / "commands.csv"
|
|
20
|
+
|
|
9
21
|
|
|
10
|
-
def
|
|
22
|
+
def packaged_csv_path():
|
|
23
|
+
"""
|
|
24
|
+
Read-only CSV shipped inside the package.
|
|
25
|
+
"""
|
|
11
26
|
return files("cheat_cli").joinpath("data/commands.csv")
|
|
12
27
|
|
|
13
|
-
def load_df():
|
|
14
|
-
return pd.read_csv(csv_path())
|
|
15
28
|
|
|
16
|
-
def
|
|
17
|
-
|
|
29
|
+
def ensure_user_csv_exists() -> Path:
|
|
30
|
+
"""
|
|
31
|
+
Ensure user CSV exists by copying from packaged CSV on first run.
|
|
32
|
+
"""
|
|
33
|
+
path = user_data_path()
|
|
34
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
35
|
+
|
|
36
|
+
if not path.exists():
|
|
37
|
+
shutil.copy(packaged_csv_path(), path)
|
|
38
|
+
|
|
39
|
+
return path
|
|
40
|
+
|
|
18
41
|
|
|
19
|
-
def
|
|
42
|
+
def load_df() -> pd.DataFrame:
|
|
43
|
+
return pd.read_csv(ensure_user_csv_exists())
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def save_df(df: pd.DataFrame):
|
|
47
|
+
df.to_csv(user_data_path(), index=False)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# ===============================
|
|
51
|
+
# Output Helpers
|
|
52
|
+
# ===============================
|
|
53
|
+
|
|
54
|
+
def print_table(df: pd.DataFrame):
|
|
20
55
|
if df.empty:
|
|
21
56
|
print("\033[91mNo results found.\033[0m")
|
|
22
57
|
return
|
|
58
|
+
|
|
23
59
|
print(tabulate(df, headers="keys", tablefmt="fancy_grid", showindex=False))
|
|
24
60
|
|
|
25
|
-
# ---------- Core Features ----------
|
|
26
61
|
|
|
27
|
-
|
|
62
|
+
# ===============================
|
|
63
|
+
# Core Features
|
|
64
|
+
# ===============================
|
|
65
|
+
|
|
66
|
+
def search(df: pd.DataFrame, term: str):
|
|
28
67
|
term = term.lower()
|
|
29
68
|
mask = (
|
|
30
69
|
df["tool"].str.lower().str.contains(term) |
|
|
@@ -34,8 +73,10 @@ def search(df, term):
|
|
|
34
73
|
)
|
|
35
74
|
print_table(df[mask])
|
|
36
75
|
|
|
37
|
-
|
|
76
|
+
|
|
77
|
+
def add_interactive(df: pd.DataFrame):
|
|
38
78
|
print("\033[94mInteractive add mode\033[0m")
|
|
79
|
+
|
|
39
80
|
tool = input("Tool: ").strip()
|
|
40
81
|
command = input("Command: ").strip()
|
|
41
82
|
description = input("Description: ").strip()
|
|
@@ -49,14 +90,17 @@ def add_interactive(df):
|
|
|
49
90
|
save_df(df)
|
|
50
91
|
print("\033[92m✅ Command added.\033[0m")
|
|
51
92
|
|
|
52
|
-
|
|
93
|
+
|
|
94
|
+
def delete_command(df: pd.DataFrame, query: str):
|
|
53
95
|
matches = df[df["command"].str.contains(query, case=False)]
|
|
96
|
+
|
|
54
97
|
if matches.empty:
|
|
55
98
|
print("\033[91mNo match found.\033[0m")
|
|
56
99
|
return
|
|
57
100
|
|
|
58
101
|
print_table(matches)
|
|
59
102
|
confirm = input("Delete these entries? (yes/no): ").lower()
|
|
103
|
+
|
|
60
104
|
if confirm != "yes":
|
|
61
105
|
print("Cancelled.")
|
|
62
106
|
return
|
|
@@ -65,23 +109,35 @@ def delete_command(df, query):
|
|
|
65
109
|
save_df(df)
|
|
66
110
|
print("\033[92m✅ Deleted.\033[0m")
|
|
67
111
|
|
|
68
|
-
|
|
112
|
+
|
|
113
|
+
# ===============================
|
|
114
|
+
# Entry Point
|
|
115
|
+
# ===============================
|
|
69
116
|
|
|
70
117
|
def main():
|
|
71
118
|
df = load_df()
|
|
72
119
|
|
|
73
120
|
if len(sys.argv) < 2:
|
|
74
|
-
print("Usage:
|
|
121
|
+
print("Usage:")
|
|
122
|
+
print(" cheat <search-term>")
|
|
123
|
+
print(" cheat add")
|
|
124
|
+
print(" cheat delete <query>")
|
|
75
125
|
return
|
|
76
126
|
|
|
77
127
|
cmd = sys.argv[1]
|
|
78
128
|
|
|
79
129
|
if cmd == "add":
|
|
80
130
|
add_interactive(df)
|
|
131
|
+
|
|
81
132
|
elif cmd == "delete":
|
|
82
133
|
if len(sys.argv) < 3:
|
|
83
134
|
print("Usage: cheat delete <query>")
|
|
84
135
|
return
|
|
85
136
|
delete_command(df, sys.argv[2])
|
|
137
|
+
|
|
86
138
|
else:
|
|
87
139
|
search(df, cmd)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
if __name__ == "__main__":
|
|
143
|
+
main()
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cheat-cli
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: A terminal-first cheat sheet
|
|
5
|
-
Author
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: A terminal-first personal cheat sheet for Linux developers
|
|
5
|
+
Author: Rejish
|
|
6
6
|
License: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/RejishJ/cheat-cli
|
|
8
|
-
Project-URL: Repository, https://github.com/RejishJ/cheat-cli
|
|
9
7
|
Requires-Python: >=3.8
|
|
10
8
|
Description-Content-Type: text/markdown
|
|
11
9
|
License-File: LICENSE
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
2
3
|
README.md
|
|
3
4
|
pyproject.toml
|
|
4
5
|
cheat_cli/__init__.py
|
|
@@ -8,4 +9,5 @@ cheat_cli.egg-info/SOURCES.txt
|
|
|
8
9
|
cheat_cli.egg-info/dependency_links.txt
|
|
9
10
|
cheat_cli.egg-info/entry_points.txt
|
|
10
11
|
cheat_cli.egg-info/requires.txt
|
|
11
|
-
cheat_cli.egg-info/top_level.txt
|
|
12
|
+
cheat_cli.egg-info/top_level.txt
|
|
13
|
+
cheat_cli/data/commands.csv
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[project]
|
|
7
|
+
name = "cheat-cli"
|
|
8
|
+
version = "0.1.2"
|
|
9
|
+
description = "A terminal-first personal cheat sheet for Linux developers"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [{name = "Rejish"}]
|
|
13
|
+
dependencies = ["pandas", "tabulate"]
|
|
14
|
+
requires-python = ">=3.8"
|
|
15
|
+
|
|
16
|
+
[project.scripts]
|
|
17
|
+
cheat = "cheat_cli.cli:main"
|
|
18
|
+
|
|
19
|
+
[tool.setuptools]
|
|
20
|
+
include-package-data = true
|
cheat_cli-0.1.0/pyproject.toml
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=64", "wheel"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "cheat-cli"
|
|
7
|
-
version = "0.1.0"
|
|
8
|
-
description = "A terminal-first cheat sheet CLI for Linux developers"
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.8"
|
|
11
|
-
license = { text = "MIT" }
|
|
12
|
-
authors = [
|
|
13
|
-
{ name = "RejishJ", email = "rejish.j.d@gmail.com" }
|
|
14
|
-
]
|
|
15
|
-
dependencies = [
|
|
16
|
-
"pandas",
|
|
17
|
-
"tabulate"
|
|
18
|
-
]
|
|
19
|
-
|
|
20
|
-
[project.urls]
|
|
21
|
-
Homepage = "https://github.com/RejishJ/cheat-cli"
|
|
22
|
-
Repository = "https://github.com/RejishJ/cheat-cli"
|
|
23
|
-
|
|
24
|
-
[project.scripts]
|
|
25
|
-
cheat = "cheat_cli.cli:main"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|