flyshell 1.2.6__tar.gz → 1.2.8__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.
- {flyshell-1.2.6/src/flyshell.egg-info → flyshell-1.2.8}/PKG-INFO +1 -1
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/builtin/fs.py +1 -1
- flyshell-1.2.8/src/flyshell/builtin/pkg.py +60 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/constants.py +2 -2
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/core/env.py +68 -1
- {flyshell-1.2.6 → flyshell-1.2.8/src/flyshell.egg-info}/PKG-INFO +1 -1
- {flyshell-1.2.6 → flyshell-1.2.8}/tests/test_pkg.py +2 -2
- flyshell-1.2.6/src/flyshell/builtin/pkg.py +0 -33
- {flyshell-1.2.6 → flyshell-1.2.8}/LICENSE +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/README.md +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/pyproject.toml +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/setup.cfg +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/__init__.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/abstract/__init__.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/abstract/base_cmd.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/abstract/base_plugin.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/abstract/parent_cmd.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/builtin/__init__.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/builtin/diskops.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/builtin/system.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/builtin/utils.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/core/__init__.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/core/auth.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/core/console.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/core/data.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/core/directory.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/core/loader.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell/main.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell.egg-info/SOURCES.txt +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell.egg-info/dependency_links.txt +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell.egg-info/entry_points.txt +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell.egg-info/requires.txt +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/src/flyshell.egg-info/top_level.txt +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/tests/test_auth.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/tests/test_data.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/tests/test_directory.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/tests/test_diskops.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/tests/test_env_keys.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/tests/test_fs.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/tests/test_loader.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/tests/test_security.py +0 -0
- {flyshell-1.2.6 → flyshell-1.2.8}/tests/test_utils.py +0 -0
|
@@ -83,7 +83,7 @@ class FsDel(BaseCmd):
|
|
|
83
83
|
return (0, "\nAll non-auth system data purged successfully.\n")
|
|
84
84
|
return (1, "\nAction cancelled.\n")
|
|
85
85
|
case _:
|
|
86
|
-
return (1, f"\nCommand Error: Unknown target '{target}'
|
|
86
|
+
return (1, f"\nCommand Error: Unknown target '{target}'\n")
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
class FsInfo(BaseCmd):
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# src\flyshell\builtin\pkg.py
|
|
2
|
+
|
|
3
|
+
from typing import List, Tuple
|
|
4
|
+
from flyshell.abstract.base_cmd import BaseCmd
|
|
5
|
+
from flyshell.abstract.parent_cmd import ParentCmd
|
|
6
|
+
from flyshell.core import env
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PkgApi(BaseCmd):
|
|
10
|
+
name: str = "api"
|
|
11
|
+
description: str = "View configured package/plugin API keys"
|
|
12
|
+
min_args: int = 1
|
|
13
|
+
options: str = "'add'/'del'/'edit'/'view', then package name and key name details"
|
|
14
|
+
aliases: List[str] = ["keys"]
|
|
15
|
+
|
|
16
|
+
def execute(self, args: List[str]) -> Tuple[int, str]:
|
|
17
|
+
arg = args[0]
|
|
18
|
+
remaining_args = args[1:]
|
|
19
|
+
match arg:
|
|
20
|
+
case "add" | "edit":
|
|
21
|
+
if len(remaining_args) < 3:
|
|
22
|
+
return (
|
|
23
|
+
1,
|
|
24
|
+
"\nCommand Error: Define a package name, a key name and a value.\n",
|
|
25
|
+
)
|
|
26
|
+
plugin_name = remaining_args[0]
|
|
27
|
+
key_name = remaining_args[1]
|
|
28
|
+
val = " ".join(remaining_args[2:])
|
|
29
|
+
code, output = env.set_plugin_api_key(plugin_name, key_name, val)
|
|
30
|
+
return (code, f"\n{output}\n")
|
|
31
|
+
case "del" | "rm":
|
|
32
|
+
if len(remaining_args) < 2:
|
|
33
|
+
return (
|
|
34
|
+
1,
|
|
35
|
+
"\nCommand Error: define a package name and a key name for deletion.\n",
|
|
36
|
+
)
|
|
37
|
+
plugin_name = remaining_args[0]
|
|
38
|
+
key_name = remaining_args[1]
|
|
39
|
+
code, output = env.remove_plugin_api_key(plugin_name, key_name)
|
|
40
|
+
return (code, f"\n{output}\n")
|
|
41
|
+
case "view":
|
|
42
|
+
if not remaining_args:
|
|
43
|
+
code, output = env.get_all_keys()
|
|
44
|
+
else:
|
|
45
|
+
package_name = remaining_args[0]
|
|
46
|
+
code, output = env.get_plugin_keys_formatted(package_name)
|
|
47
|
+
return (code, f"\n{output}\n")
|
|
48
|
+
case _:
|
|
49
|
+
return (1, f"\nCommand Error: Unknown target '{arg}'\n")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class Pkg(ParentCmd):
|
|
53
|
+
name: str = "pkg"
|
|
54
|
+
description: str = "Manage Flyshell packages, plugins, and dependencies"
|
|
55
|
+
aliases: List[str] = ["package"]
|
|
56
|
+
|
|
57
|
+
def get_subcommands(self) -> List[BaseCmd]:
|
|
58
|
+
return [
|
|
59
|
+
PkgApi(),
|
|
60
|
+
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# src
|
|
1
|
+
# src\flyshell\core\env.py
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from flyshell import constants as c
|
|
@@ -127,3 +127,70 @@ def get_plugin_keys_formatted(target_name: str) -> tuple[int, str]:
|
|
|
127
127
|
if k_lower not in seen_keys:
|
|
128
128
|
lines.append(f"{orig_k} = {val} [Optional/Extra]")
|
|
129
129
|
return (0, "\n".join(lines))
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def set_plugin_api_key(plugin_name: str, key_name: str, value: str) -> tuple[int, str]:
|
|
133
|
+
if not plugin_name or not key_name:
|
|
134
|
+
return (1, "Command Error: Both plugin name and key name are required.")
|
|
135
|
+
target_key = f"{plugin_name.strip().lower()}_{key_name.strip().upper()}"
|
|
136
|
+
clean_val = value.strip().strip("\"'")
|
|
137
|
+
env_path = get_env_path()
|
|
138
|
+
try:
|
|
139
|
+
env_path.parent.mkdir(parents=True, exist_ok=True)
|
|
140
|
+
if not env_path.exists():
|
|
141
|
+
env_path.touch()
|
|
142
|
+
lines = env_path.read_text(encoding="utf-8").splitlines()
|
|
143
|
+
updated = False
|
|
144
|
+
new_lines = []
|
|
145
|
+
for line in lines:
|
|
146
|
+
stripped = line.strip()
|
|
147
|
+
if stripped and not stripped.startswith("#") and "=" in stripped:
|
|
148
|
+
k, _ = stripped.split("=", 1)
|
|
149
|
+
clean_k = k.strip().replace("[", "").replace("]", "")
|
|
150
|
+
if clean_k.lower() == target_key.lower():
|
|
151
|
+
new_lines.append(f"{target_key}={clean_val}")
|
|
152
|
+
updated = True
|
|
153
|
+
continue
|
|
154
|
+
new_lines.append(line)
|
|
155
|
+
if not updated:
|
|
156
|
+
new_lines.append(f"{target_key}={clean_val}")
|
|
157
|
+
env_path.write_text("\n".join(new_lines) + "\n", encoding="utf-8")
|
|
158
|
+
action = "Updated" if updated else "Added"
|
|
159
|
+
return (0, f"SUCCESS! {action} key '{target_key}'")
|
|
160
|
+
|
|
161
|
+
except Exception as e:
|
|
162
|
+
return (1, f"File Error: Failed to write to '{env_path}': {e}")
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def remove_plugin_api_key(plugin_name: str, key_name: str) -> tuple[int, str]:
|
|
166
|
+
if not plugin_name or not key_name:
|
|
167
|
+
return (1, "Command Error: Both plugin name and key name are required.")
|
|
168
|
+
target_key = f"{plugin_name.strip().lower()}_{key_name.strip().lower()}"
|
|
169
|
+
env_path = get_env_path()
|
|
170
|
+
if not env_path.exists():
|
|
171
|
+
return (
|
|
172
|
+
1,
|
|
173
|
+
f"File Config Error: Environment file not found at '{env_path}'",
|
|
174
|
+
)
|
|
175
|
+
try:
|
|
176
|
+
lines = env_path.read_text(encoding="utf-8").splitlines()
|
|
177
|
+
new_lines = []
|
|
178
|
+
found = False
|
|
179
|
+
for line in lines:
|
|
180
|
+
stripped = line.strip()
|
|
181
|
+
if stripped and not stripped.startswith("#") and "=" in stripped:
|
|
182
|
+
k, _ = stripped.split("=", 1)
|
|
183
|
+
clean_k = k.strip().replace("[", "").replace("]", "").lower()
|
|
184
|
+
if clean_k == target_key:
|
|
185
|
+
found = True
|
|
186
|
+
continue
|
|
187
|
+
new_lines.append(line)
|
|
188
|
+
if not found:
|
|
189
|
+
return (
|
|
190
|
+
1,
|
|
191
|
+
f"Command Error: Key '{target_key}' not found in '{env_path.name}'",
|
|
192
|
+
)
|
|
193
|
+
env_path.write_text("\n".join(new_lines) + "\n", encoding="utf-8")
|
|
194
|
+
return (0, f"SUCCESS! Removed key '{target_key}' from Flyshell environment.")
|
|
195
|
+
except Exception as e:
|
|
196
|
+
return (1, f"File Error: Failed to update '{env_path}': {e}")
|
|
@@ -36,7 +36,7 @@ def test_pkg_unknown_subcommand():
|
|
|
36
36
|
def test_pkg_api_all_keys(mock_env_file):
|
|
37
37
|
mock_env_file.write_text("dummy_token=123\n")
|
|
38
38
|
parent = pkg.Pkg()
|
|
39
|
-
code, msg = parent.execute(["api"])
|
|
39
|
+
code, msg = parent.execute(["api", "view"])
|
|
40
40
|
assert code == 0
|
|
41
41
|
assert "dummy_token = 123" in msg
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ def test_pkg_api_all_keys(mock_env_file):
|
|
|
44
44
|
def test_pkg_api_plugin_keys(mock_env_file):
|
|
45
45
|
mock_env_file.write_text("weather_key=secret\nother_key=skip\n")
|
|
46
46
|
parent = pkg.Pkg()
|
|
47
|
-
code, msg = parent.execute(["api", "weather"])
|
|
47
|
+
code, msg = parent.execute(["api", "view", "weather"])
|
|
48
48
|
assert code == 0
|
|
49
49
|
assert "key = secret" in msg
|
|
50
50
|
assert "other_key" not in msg
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# src\flyshell\builtin\pkg.py
|
|
2
|
-
|
|
3
|
-
from typing import List, Tuple
|
|
4
|
-
from flyshell.abstract.base_cmd import BaseCmd
|
|
5
|
-
from flyshell.abstract.parent_cmd import ParentCmd
|
|
6
|
-
from flyshell.core import env
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class PkgApi(BaseCmd):
|
|
10
|
-
name: str = "api"
|
|
11
|
-
description: str = "View configured package/plugin API keys"
|
|
12
|
-
min_args: int = 0
|
|
13
|
-
options: str = "Package name"
|
|
14
|
-
aliases: List[str] = ["keys"]
|
|
15
|
-
|
|
16
|
-
def execute(self, args: List[str]) -> Tuple[int, str]:
|
|
17
|
-
if not args:
|
|
18
|
-
code, output = env.get_all_keys()
|
|
19
|
-
else:
|
|
20
|
-
package_name = args[0]
|
|
21
|
-
code, output = env.get_plugin_keys_formatted(package_name)
|
|
22
|
-
return (code, f"\n{output}\n")
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class Pkg(ParentCmd):
|
|
26
|
-
name: str = "pkg"
|
|
27
|
-
description: str = "Manage Flyshell packages, plugins, and dependencies"
|
|
28
|
-
aliases: List[str] = ["package"]
|
|
29
|
-
|
|
30
|
-
def get_subcommands(self) -> List[BaseCmd]:
|
|
31
|
-
return [
|
|
32
|
-
PkgApi(),
|
|
33
|
-
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|