flyshell 1.5.9__tar.gz → 1.6.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.
- {flyshell-1.5.9/src/flyshell.egg-info → flyshell-1.6.0}/PKG-INFO +3 -3
- {flyshell-1.5.9 → flyshell-1.6.0}/README.md +2 -2
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/abstract/base_cmd.py +2 -2
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/abstract/base_plugin.py +10 -10
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/abstract/parent_cmd.py +4 -4
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/accounts/auth.py +3 -3
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/builtin/fs.py +9 -19
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/builtin/system.py +5 -44
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/builtin/utils.py +6 -6
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/constants.py +3 -3
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/core/console.py +2 -2
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/core/data.py +36 -19
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/core/directory.py +3 -3
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/main.py +1 -1
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/native/diskops_handler.py +9 -9
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/startup/deps.py +2 -2
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/startup/env.py +3 -3
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/startup/loader.py +6 -19
- {flyshell-1.5.9 → flyshell-1.6.0/src/flyshell.egg-info}/PKG-INFO +3 -3
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell.egg-info/SOURCES.txt +0 -1
- {flyshell-1.5.9 → flyshell-1.6.0}/tests/test_env.py +0 -18
- flyshell-1.5.9/tests/test_security.py +0 -42
- {flyshell-1.5.9 → flyshell-1.6.0}/LICENSE +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/MANIFEST.in +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/diskops.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/posix/cat.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/posix/cp.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/posix/dir.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/posix/mkdir.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/posix/mv.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/posix/rename.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/posix/rm.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/posix/rmdir.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/posix/touch.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/shared/dir_types.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/shared/dir_types.h +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/shared/native_errors.h +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/shared/win32_utf.h +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/win32/cat.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/win32/cp.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/win32/dir.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/win32/mkdir.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/win32/mv.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/win32/rename.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/win32/rm.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/win32/rmdir.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/c_src/diskops/win32/touch.c +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/pyproject.toml +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/setup.cfg +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/setup.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/__init__.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/abstract/__init__.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/accounts/__init__.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/bin/__init__.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/builtin/__init__.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/builtin/pkg.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/core/__init__.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/native/__init__.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/native/diskops_bridge.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/native/legacy/__init__.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/native/legacy/diskops.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/startup/__init__.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell/startup/seasonal.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell.egg-info/dependency_links.txt +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell.egg-info/entry_points.txt +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell.egg-info/requires.txt +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/src/flyshell.egg-info/top_level.txt +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/tests/test_auth.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/tests/test_data.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/tests/test_deps.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/tests/test_directory.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/tests/test_diskops_ext.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/tests/test_diskops_lgc.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/tests/test_fs.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/tests/test_loader.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/tests/test_pkg.py +0 -0
- {flyshell-1.5.9 → flyshell-1.6.0}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flyshell
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.0
|
|
4
4
|
Summary: A modular, zero-dependency command-line environment in Python.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -23,7 +23,7 @@ Dynamic: license-file
|
|
|
23
23
|

|
|
24
24
|

|
|
25
25
|
|
|
26
|
-
> Documentation last updated: v1.
|
|
26
|
+
> Documentation last updated: v1.6.0
|
|
27
27
|
|
|
28
28
|
A modular, zero-dependency command-line environment and extensible runtime interface built in Python with compiled C-extensions.
|
|
29
29
|
|
|
@@ -38,7 +38,7 @@ No extra packages required, just install and enjoy!
|
|
|
38
38
|
3. **Secure Authentication**: Flyshell uses salted PBKDF2 HMAC (SHA-256, 600,000 iterations) with constant-time equality comparisons to prevent timing attacks on password information.
|
|
39
39
|
4. **Cross-Platform Support**: Flyshell is fully supported by Windows (NT), macOS (Darwin) and Linux installations with native OS management and POSIX-aware parsing. Note that Flyshell is **not** supported by any other systems.
|
|
40
40
|
5. **State and History Persistence**: Flyshell has a fully encapsulated SQL storage system using SQLite3 providing session metrics and ISO 8601 UTC audit logging.
|
|
41
|
-
6. **Automatic C-Extension Compilation**: If installed via `pip` on Windows or Linux, Flyshell is shipped with pre-compiled wheels. For macOS users, Xcode CLI
|
|
41
|
+
6. **Automatic C-Extension Compilation**: If installed via `pip` on Windows or Linux, Flyshell is shipped with pre-compiled wheels. For macOS users, Xcode CLI Tools is required as macOS builds install from source.
|
|
42
42
|
|
|
43
43
|
## System Requirements
|
|
44
44
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|

|
|
7
7
|

|
|
8
8
|
|
|
9
|
-
> Documentation last updated: v1.
|
|
9
|
+
> Documentation last updated: v1.6.0
|
|
10
10
|
|
|
11
11
|
A modular, zero-dependency command-line environment and extensible runtime interface built in Python with compiled C-extensions.
|
|
12
12
|
|
|
@@ -21,7 +21,7 @@ No extra packages required, just install and enjoy!
|
|
|
21
21
|
3. **Secure Authentication**: Flyshell uses salted PBKDF2 HMAC (SHA-256, 600,000 iterations) with constant-time equality comparisons to prevent timing attacks on password information.
|
|
22
22
|
4. **Cross-Platform Support**: Flyshell is fully supported by Windows (NT), macOS (Darwin) and Linux installations with native OS management and POSIX-aware parsing. Note that Flyshell is **not** supported by any other systems.
|
|
23
23
|
5. **State and History Persistence**: Flyshell has a fully encapsulated SQL storage system using SQLite3 providing session metrics and ISO 8601 UTC audit logging.
|
|
24
|
-
6. **Automatic C-Extension Compilation**: If installed via `pip` on Windows or Linux, Flyshell is shipped with pre-compiled wheels. For macOS users, Xcode CLI
|
|
24
|
+
6. **Automatic C-Extension Compilation**: If installed via `pip` on Windows or Linux, Flyshell is shipped with pre-compiled wheels. For macOS users, Xcode CLI Tools is required as macOS builds install from source.
|
|
25
25
|
|
|
26
26
|
## System Requirements
|
|
27
27
|
|
|
@@ -10,7 +10,7 @@ class BaseCmd:
|
|
|
10
10
|
options: Optional[str] = None
|
|
11
11
|
aliases: Optional[List[str]] = None
|
|
12
12
|
|
|
13
|
-
def __init__(self):
|
|
13
|
+
def __init__(self) -> None:
|
|
14
14
|
if self.aliases is None:
|
|
15
15
|
self.aliases = []
|
|
16
16
|
else:
|
|
@@ -21,7 +21,7 @@ class BaseCmd:
|
|
|
21
21
|
f"Command '{self.__class__.__name__}' has not implemented the execute method"
|
|
22
22
|
)
|
|
23
23
|
|
|
24
|
-
def help(self, prefix: str = ""):
|
|
24
|
+
def help(self, prefix: str = "") -> None:
|
|
25
25
|
full_name = f"{prefix} {self.name}".strip() if prefix else self.name
|
|
26
26
|
print(f"\nCommand: {full_name}")
|
|
27
27
|
if prefix:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from flyshell.core import data
|
|
4
4
|
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import Optional
|
|
6
|
+
from typing import Any, Optional
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class BasePlugin:
|
|
@@ -17,7 +17,7 @@ class BasePlugin:
|
|
|
17
17
|
api_keys: Optional[list] = None
|
|
18
18
|
third_pty_libs: Optional[list] = None
|
|
19
19
|
|
|
20
|
-
def __init__(self, context: dict):
|
|
20
|
+
def __init__(self, context: dict) -> None:
|
|
21
21
|
self.api_keys = list(self.api_keys) if self.api_keys else []
|
|
22
22
|
self.third_pty_libs = list(self.third_pty_libs) if self.third_pty_libs else []
|
|
23
23
|
self.context = context
|
|
@@ -27,7 +27,7 @@ class BasePlugin:
|
|
|
27
27
|
self.env_file_path = context.get("env_path", None)
|
|
28
28
|
self.on_load()
|
|
29
29
|
|
|
30
|
-
def get_api_key(self, key_name: str, default=None):
|
|
30
|
+
def get_api_key(self, key_name: str, default: Any = None) -> Any:
|
|
31
31
|
if key_name in self.api_keys_data:
|
|
32
32
|
return self.api_keys_data[key_name]
|
|
33
33
|
target = key_name.lower()
|
|
@@ -36,16 +36,16 @@ class BasePlugin:
|
|
|
36
36
|
return v
|
|
37
37
|
return default
|
|
38
38
|
|
|
39
|
-
def on_load(self):
|
|
39
|
+
def on_load(self) -> None:
|
|
40
40
|
pass
|
|
41
41
|
|
|
42
|
-
def on_unload(self):
|
|
42
|
+
def on_unload(self) -> None:
|
|
43
43
|
pass
|
|
44
44
|
|
|
45
|
-
def execute(self, args: list):
|
|
45
|
+
def execute(self, args: list) -> Any:
|
|
46
46
|
raise NotImplementedError("Plugins must implement the execute method")
|
|
47
47
|
|
|
48
|
-
def help(self):
|
|
48
|
+
def help(self) -> None:
|
|
49
49
|
lines = [
|
|
50
50
|
f"\nPlugin: {self.name} (v{self.version})",
|
|
51
51
|
f"Description: {self.description}",
|
|
@@ -79,10 +79,10 @@ class BasePlugin:
|
|
|
79
79
|
return True
|
|
80
80
|
return False
|
|
81
81
|
|
|
82
|
-
def get_data(self, key: str, default=None):
|
|
82
|
+
def get_data(self, key: str, default: Any = None) -> Any:
|
|
83
83
|
return self.storage.get(key, default)
|
|
84
84
|
|
|
85
|
-
def set_data(self, key: str, value):
|
|
85
|
+
def set_data(self, key: str, value: Any) -> None:
|
|
86
86
|
self.storage[key] = value
|
|
87
87
|
self.save_storage()
|
|
88
88
|
|
|
@@ -99,7 +99,7 @@ class BasePlugin:
|
|
|
99
99
|
self.context["storage"] = fresh_data
|
|
100
100
|
return self.storage
|
|
101
101
|
|
|
102
|
-
def save_storage(self):
|
|
102
|
+
def save_storage(self) -> None:
|
|
103
103
|
existing_keys = set(data.get_all_plugin_data(self.plugin_name).keys())
|
|
104
104
|
for stale_key in existing_keys - set(self.storage.keys()):
|
|
105
105
|
data.delete_plugin_data(self.plugin_name, stale_key)
|
|
@@ -8,12 +8,12 @@ from typing import Dict, List, Tuple
|
|
|
8
8
|
class ParentCmd(BaseCmd):
|
|
9
9
|
min_args: int = 1
|
|
10
10
|
|
|
11
|
-
def __init__(self):
|
|
11
|
+
def __init__(self) -> None:
|
|
12
12
|
super().__init__()
|
|
13
13
|
self._sub_registry: Dict[str, BaseCmd] = {}
|
|
14
14
|
self._build_registry()
|
|
15
15
|
|
|
16
|
-
def _build_registry(self):
|
|
16
|
+
def _build_registry(self) -> None:
|
|
17
17
|
for cmd_obj in self.get_subcommands():
|
|
18
18
|
self._sub_registry[cmd_obj.name] = cmd_obj
|
|
19
19
|
for alias in getattr(cmd_obj, "aliases", []):
|
|
@@ -22,7 +22,7 @@ class ParentCmd(BaseCmd):
|
|
|
22
22
|
def get_subcommands(self) -> List[BaseCmd]:
|
|
23
23
|
return []
|
|
24
24
|
|
|
25
|
-
def help(self):
|
|
25
|
+
def help(self) -> None:
|
|
26
26
|
print(f"\nCommand Family: {self.name}")
|
|
27
27
|
print(f"Description: {self.description}")
|
|
28
28
|
print(f"\nSubcommands of '{self.name}':")
|
|
@@ -50,7 +50,7 @@ class ParentCmd(BaseCmd):
|
|
|
50
50
|
sub_args = args[1:]
|
|
51
51
|
if sub_name not in self._sub_registry:
|
|
52
52
|
err = (
|
|
53
|
-
f"\nCommand Error: Unknown subcommand '{sub_name}' for '{self.name}'
|
|
53
|
+
f"\nCommand Error: Unknown subcommand '{sub_name}' for '{self.name}'\n"
|
|
54
54
|
f"Use '{self.name} -h' or '--help' to see all valid subcommands.\n"
|
|
55
55
|
)
|
|
56
56
|
return (1, err)
|
|
@@ -9,7 +9,7 @@ import re
|
|
|
9
9
|
import secrets
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
def hash_password(password, salt=None):
|
|
12
|
+
def hash_password(password: str, salt: bytes | str | None = None) -> tuple[str, str]:
|
|
13
13
|
if salt is None:
|
|
14
14
|
salt = secrets.token_bytes(16)
|
|
15
15
|
elif isinstance(salt, str):
|
|
@@ -77,7 +77,7 @@ def setup_acc() -> bool:
|
|
|
77
77
|
return True
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
def login_flow(is_lock=False) -> bool:
|
|
80
|
+
def login_flow(is_lock: bool = False) -> bool:
|
|
81
81
|
auth_info = data.get_auth()
|
|
82
82
|
if not auth_info or "hash" not in auth_info:
|
|
83
83
|
if not setup_acc():
|
|
@@ -113,7 +113,7 @@ class Lock(BaseCmd):
|
|
|
113
113
|
options = None
|
|
114
114
|
aliases = []
|
|
115
115
|
|
|
116
|
-
def execute(self, args):
|
|
116
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
117
117
|
if login_flow(is_lock=True):
|
|
118
118
|
return (0, "")
|
|
119
119
|
else:
|
|
@@ -18,7 +18,7 @@ class FsDel(BaseCmd):
|
|
|
18
18
|
options = "'history', 'all', 'plugin <file>'"
|
|
19
19
|
aliases = ["purge"]
|
|
20
20
|
|
|
21
|
-
def execute(self, args):
|
|
21
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
22
22
|
if len(args) < 1:
|
|
23
23
|
return (1, "\nCommand Error: 'fs del' requires a target.\n")
|
|
24
24
|
target = args[0].lower()
|
|
@@ -35,16 +35,6 @@ class FsDel(BaseCmd):
|
|
|
35
35
|
data.clear_history()
|
|
36
36
|
return (0, "\nCommand history purged successfully.\n")
|
|
37
37
|
return (1, "\nAction cancelled.\n")
|
|
38
|
-
case "config":
|
|
39
|
-
if len(args) < 2:
|
|
40
|
-
return (
|
|
41
|
-
1,
|
|
42
|
-
"\nCommand Error: Please specify a configuration key to delete.\n",
|
|
43
|
-
)
|
|
44
|
-
key = args[1]
|
|
45
|
-
if data.delete_config(key):
|
|
46
|
-
return (0, f"\nConfig setting '{key}' deleted.\n")
|
|
47
|
-
return (1, f"\nConfig Error: Setting '{key}' not found.\n")
|
|
48
38
|
case "plugin":
|
|
49
39
|
if len(args) < 2:
|
|
50
40
|
return (
|
|
@@ -67,7 +57,7 @@ class FsDel(BaseCmd):
|
|
|
67
57
|
)
|
|
68
58
|
return (
|
|
69
59
|
1,
|
|
70
|
-
f"\nPlugin Error: No data found for plugin '{plugin_name}'
|
|
60
|
+
f"\nPlugin Error: No data found for plugin '{plugin_name}'\n",
|
|
71
61
|
)
|
|
72
62
|
return (1, "\nAction cancelled.\n")
|
|
73
63
|
case "all":
|
|
@@ -94,7 +84,7 @@ class FsInfo(BaseCmd):
|
|
|
94
84
|
options = None
|
|
95
85
|
aliases = []
|
|
96
86
|
|
|
97
|
-
def execute(self, args):
|
|
87
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
98
88
|
return (
|
|
99
89
|
0,
|
|
100
90
|
(
|
|
@@ -116,7 +106,7 @@ class FsLicence(BaseCmd):
|
|
|
116
106
|
options = None
|
|
117
107
|
aliases = ["license"]
|
|
118
108
|
|
|
119
|
-
def execute(self, args):
|
|
109
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
120
110
|
return (
|
|
121
111
|
0,
|
|
122
112
|
(
|
|
@@ -137,7 +127,7 @@ class FsPlugins(BaseCmd):
|
|
|
137
127
|
options = None
|
|
138
128
|
aliases = ["plugin"]
|
|
139
129
|
|
|
140
|
-
def execute(self, args):
|
|
130
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
141
131
|
lines = ["\nInstalled Plugins:"]
|
|
142
132
|
if c.PLUGINS:
|
|
143
133
|
for name, plugin in c.PLUGINS.items():
|
|
@@ -157,7 +147,7 @@ class FsSeason(BaseCmd):
|
|
|
157
147
|
options = None
|
|
158
148
|
aliases = []
|
|
159
149
|
|
|
160
|
-
def execute(self, args):
|
|
150
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
161
151
|
season = seasonal.get_season(return_icons=False)
|
|
162
152
|
if not season:
|
|
163
153
|
return (0, "\nNo seasonal modes are active at present.\n")
|
|
@@ -172,7 +162,7 @@ class FsStatus(BaseCmd):
|
|
|
172
162
|
options = None
|
|
173
163
|
aliases = []
|
|
174
164
|
|
|
175
|
-
def execute(self, args):
|
|
165
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
176
166
|
uptime = int(time.time() - c.SESSION_START_TIME)
|
|
177
167
|
mins, secs = divmod(uptime, 60)
|
|
178
168
|
hours, mins = divmod(mins, 60)
|
|
@@ -205,7 +195,7 @@ class FsVersion(BaseCmd):
|
|
|
205
195
|
options = None
|
|
206
196
|
aliases = []
|
|
207
197
|
|
|
208
|
-
def execute(self, args):
|
|
198
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
209
199
|
return (
|
|
210
200
|
0,
|
|
211
201
|
(
|
|
@@ -222,7 +212,7 @@ class Fs(ParentCmd):
|
|
|
222
212
|
description = "Execute core Flyshell control and utility functions"
|
|
223
213
|
aliases = []
|
|
224
214
|
|
|
225
|
-
def get_subcommands(self):
|
|
215
|
+
def get_subcommands(self) -> list[BaseCmd]:
|
|
226
216
|
return [
|
|
227
217
|
FsDel(),
|
|
228
218
|
FsInfo(),
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from flyshell import constants as c
|
|
4
4
|
from flyshell.abstract.base_cmd import BaseCmd
|
|
5
|
-
from flyshell.accounts import auth
|
|
6
|
-
from flyshell.core import data
|
|
7
5
|
|
|
8
|
-
import getpass
|
|
9
6
|
import os
|
|
10
7
|
import shutil
|
|
11
8
|
import subprocess
|
|
@@ -18,7 +15,7 @@ class Cd(BaseCmd):
|
|
|
18
15
|
options = "Directory name (default is Home)"
|
|
19
16
|
aliases = []
|
|
20
17
|
|
|
21
|
-
def execute(self, args):
|
|
18
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
22
19
|
target = os.path.expanduser(" ".join(args)) if args else os.path.expanduser("~")
|
|
23
20
|
try:
|
|
24
21
|
os.chdir(target)
|
|
@@ -30,7 +27,7 @@ class Cd(BaseCmd):
|
|
|
30
27
|
except OSError as e:
|
|
31
28
|
return (
|
|
32
29
|
1,
|
|
33
|
-
f"\nCommand Error: Invalid path syntax '{target}'
|
|
30
|
+
f"\nCommand Error: Invalid path syntax '{target}' ({e.strerror})\n",
|
|
34
31
|
)
|
|
35
32
|
|
|
36
33
|
|
|
@@ -41,7 +38,7 @@ class OpenFile(BaseCmd):
|
|
|
41
38
|
options = "File path"
|
|
42
39
|
aliases = []
|
|
43
40
|
|
|
44
|
-
def execute(self, args):
|
|
41
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
45
42
|
target = " ".join(args).strip().strip('"')
|
|
46
43
|
if not target:
|
|
47
44
|
return (0, "")
|
|
@@ -72,48 +69,12 @@ class SysExe(BaseCmd):
|
|
|
72
69
|
options = "Any host command"
|
|
73
70
|
aliases = []
|
|
74
71
|
|
|
75
|
-
def execute(self, args):
|
|
72
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
76
73
|
if not args:
|
|
77
74
|
return (1, "\nCommand Error: 'sys' requires at least 1 parameter(s).\n")
|
|
78
|
-
if args[0] in ["-f", "--force"]:
|
|
79
|
-
override = True
|
|
80
|
-
cmd_args = args[1:]
|
|
81
|
-
if not cmd_args:
|
|
82
|
-
return (1, "\nCommand Error: 'sys' requires at least 1 parameter(s).\n")
|
|
83
|
-
else:
|
|
84
|
-
override = False
|
|
85
|
-
cmd_args = args
|
|
86
|
-
tokens_lower = [token.lower().strip("\"'") for token in cmd_args]
|
|
87
|
-
|
|
88
|
-
def matches_pattern(target_set):
|
|
89
|
-
for token in tokens_lower:
|
|
90
|
-
base_name = os.path.splitext(os.path.basename(token))[0]
|
|
91
|
-
if token in target_set or base_name in target_set:
|
|
92
|
-
return True
|
|
93
|
-
return False
|
|
94
|
-
|
|
95
|
-
if matches_pattern(c.BLOCKED_COMMANDS):
|
|
96
|
-
cmd_display = " ".join(cmd_args)
|
|
97
|
-
return (
|
|
98
|
-
1,
|
|
99
|
-
(
|
|
100
|
-
"\nSecurity Error: Flyshell has blocked execution of this command.\n"
|
|
101
|
-
f"This command '{cmd_display}' is permanently restricted by Flyshell safety policy.\n"
|
|
102
|
-
"Flyshell has blocked your command to prevent damage to your computer.\n"
|
|
103
|
-
),
|
|
104
|
-
)
|
|
105
|
-
if not override and matches_pattern(c.DANGER_COMMANDS):
|
|
106
|
-
password = getpass.getpass(
|
|
107
|
-
"\nThis command is restricted. To execute, enter your password: "
|
|
108
|
-
)
|
|
109
|
-
auth_info = data.get_auth() or {}
|
|
110
|
-
stored_hash = auth_info.get("hash")
|
|
111
|
-
stored_salt = auth_info.get("salt")
|
|
112
|
-
if not auth.verify_password(stored_hash, stored_salt, password):
|
|
113
|
-
return (1, "\nAccount Error: Password does not match.\n")
|
|
114
75
|
try:
|
|
115
76
|
print()
|
|
116
|
-
raw_cmd = " ".join(
|
|
77
|
+
raw_cmd = " ".join(args)
|
|
117
78
|
result = subprocess.run(raw_cmd, shell=True)
|
|
118
79
|
print()
|
|
119
80
|
return (result.returncode, "")
|
|
@@ -20,7 +20,7 @@ class Clear(BaseCmd):
|
|
|
20
20
|
options = None
|
|
21
21
|
aliases = ["cls"]
|
|
22
22
|
|
|
23
|
-
def execute(self, args):
|
|
23
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
24
24
|
return (0, c.CLEAR_SCREEN)
|
|
25
25
|
|
|
26
26
|
|
|
@@ -36,7 +36,7 @@ class Echo(BaseCmd):
|
|
|
36
36
|
options = "Message"
|
|
37
37
|
aliases = []
|
|
38
38
|
|
|
39
|
-
def execute(self, args):
|
|
39
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
40
40
|
text = " ".join(args)
|
|
41
41
|
try:
|
|
42
42
|
text = _ESCAPE_SEQ_RE.sub(
|
|
@@ -55,7 +55,7 @@ class History(BaseCmd):
|
|
|
55
55
|
options = "Entry count (default is 10)"
|
|
56
56
|
aliases = []
|
|
57
57
|
|
|
58
|
-
def execute(self, args):
|
|
58
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
59
59
|
limit = 10
|
|
60
60
|
if args:
|
|
61
61
|
sub_arg = args[0].lower()
|
|
@@ -90,7 +90,7 @@ class Kill(BaseCmd):
|
|
|
90
90
|
options = None
|
|
91
91
|
aliases = []
|
|
92
92
|
|
|
93
|
-
def execute(self, args):
|
|
93
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
94
94
|
choice = input("\nAre you sure [y/n]?: ").strip().lower()
|
|
95
95
|
if choice == "y":
|
|
96
96
|
return (-1, "\nShutting down...\n")
|
|
@@ -104,7 +104,7 @@ class Reboot(BaseCmd):
|
|
|
104
104
|
options = None
|
|
105
105
|
aliases = ["restart"]
|
|
106
106
|
|
|
107
|
-
def execute(self, args):
|
|
107
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
108
108
|
print("\nRestarting Flyshell...\n")
|
|
109
109
|
is_direct_script = (
|
|
110
110
|
sys.argv[0].lower().endswith(".exe")
|
|
@@ -133,7 +133,7 @@ class Sleep(BaseCmd):
|
|
|
133
133
|
options = "Duration (secs)"
|
|
134
134
|
aliases = []
|
|
135
135
|
|
|
136
|
-
def execute(self, args):
|
|
136
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
137
137
|
if not args or not args[0].replace(".", "", 1).isdigit():
|
|
138
138
|
return (
|
|
139
139
|
1,
|
|
@@ -28,7 +28,7 @@ def check_readline() -> bool:
|
|
|
28
28
|
return False
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
def load_history():
|
|
31
|
+
def load_history() -> None:
|
|
32
32
|
if not readline:
|
|
33
33
|
return
|
|
34
34
|
history_entries = data.get_history(limit=100)
|
|
@@ -37,7 +37,7 @@ def load_history():
|
|
|
37
37
|
readline.add_history(entry["command"])
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
def boot():
|
|
40
|
+
def boot() -> None:
|
|
41
41
|
load_history()
|
|
42
42
|
env.create_env()
|
|
43
43
|
print(c.CLEAR_SCREEN, end="")
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
from flyshell import constants as c
|
|
4
4
|
|
|
5
5
|
from pathlib import Path
|
|
6
|
+
from typing import Any
|
|
6
7
|
import json
|
|
7
8
|
import sqlite3
|
|
8
9
|
import time
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
def get_storage_size(filename=None) -> str:
|
|
12
|
+
def get_storage_size(filename: str | Path | None = None) -> str:
|
|
12
13
|
target = Path(filename) if filename is not None else c.FILE_PATH
|
|
13
14
|
if not target.exists():
|
|
14
15
|
return "File not found"
|
|
@@ -22,7 +23,7 @@ def get_storage_size(filename=None) -> str:
|
|
|
22
23
|
return f"{num_bytes:.2f} TB"
|
|
23
24
|
|
|
24
25
|
|
|
25
|
-
def _get_connection(filename=None):
|
|
26
|
+
def _get_connection(filename: str | Path | None = None) -> sqlite3.Connection:
|
|
26
27
|
target = Path(filename) if filename is not None else c.FILE_PATH
|
|
27
28
|
if str(target) != ":memory:":
|
|
28
29
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -31,7 +32,9 @@ def _get_connection(filename=None):
|
|
|
31
32
|
return conn
|
|
32
33
|
|
|
33
34
|
|
|
34
|
-
def initialise(
|
|
35
|
+
def initialise(
|
|
36
|
+
filename: str | Path | None = None, initialised: set[str] | None = None
|
|
37
|
+
) -> None:
|
|
35
38
|
target = filename if filename is not None else c.FILE_PATH
|
|
36
39
|
if initialised is None:
|
|
37
40
|
initialised = c.INITIALISED
|
|
@@ -85,7 +88,7 @@ def initialise(filename=None, initialised=None):
|
|
|
85
88
|
initialised.add(target)
|
|
86
89
|
|
|
87
90
|
|
|
88
|
-
def get_auth(filename=None) -> dict | None:
|
|
91
|
+
def get_auth(filename: str | Path | None = None) -> dict | None:
|
|
89
92
|
initialise(filename)
|
|
90
93
|
with _get_connection(filename) as conn:
|
|
91
94
|
row = conn.execute(
|
|
@@ -101,7 +104,9 @@ def get_auth(filename=None) -> dict | None:
|
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
|
|
104
|
-
def set_auth(
|
|
107
|
+
def set_auth(
|
|
108
|
+
username: str, pwd_hash: str, salt: str, filename: str | Path | None = None
|
|
109
|
+
) -> None:
|
|
105
110
|
initialise(filename)
|
|
106
111
|
now_utc = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
|
|
107
112
|
with _get_connection(filename) as conn:
|
|
@@ -115,7 +120,7 @@ def set_auth(username: str, pwd_hash: str, salt: str, filename=None) -> None:
|
|
|
115
120
|
)
|
|
116
121
|
|
|
117
122
|
|
|
118
|
-
def clear_auth(filename=None) -> bool:
|
|
123
|
+
def clear_auth(filename: str | Path | None = None) -> bool:
|
|
119
124
|
initialise(filename)
|
|
120
125
|
with _get_connection(filename) as conn:
|
|
121
126
|
with conn:
|
|
@@ -123,7 +128,9 @@ def clear_auth(filename=None) -> bool:
|
|
|
123
128
|
return cursor.rowcount > 0
|
|
124
129
|
|
|
125
130
|
|
|
126
|
-
def append_history(
|
|
131
|
+
def append_history(
|
|
132
|
+
cmd: str, timestamp: str, filename: str | Path | None = None
|
|
133
|
+
) -> None:
|
|
127
134
|
initialise(filename)
|
|
128
135
|
with _get_connection(filename) as conn:
|
|
129
136
|
with conn:
|
|
@@ -133,7 +140,9 @@ def append_history(cmd: str, timestamp: str, filename=None) -> None:
|
|
|
133
140
|
)
|
|
134
141
|
|
|
135
142
|
|
|
136
|
-
def get_history(
|
|
143
|
+
def get_history(
|
|
144
|
+
limit: int | None = None, filename: str | Path | None = None
|
|
145
|
+
) -> list[dict]:
|
|
137
146
|
initialise(filename)
|
|
138
147
|
with _get_connection(filename) as conn:
|
|
139
148
|
if limit is not None and limit > 0:
|
|
@@ -148,7 +157,7 @@ def get_history(limit: int | None = None, filename=None) -> list[dict]:
|
|
|
148
157
|
return [{"command": r[0], "timestamp": r[1]} for r in rows]
|
|
149
158
|
|
|
150
159
|
|
|
151
|
-
def clear_history(filename=None) -> bool:
|
|
160
|
+
def clear_history(filename: str | Path | None = None) -> bool:
|
|
152
161
|
initialise(filename)
|
|
153
162
|
with _get_connection(filename) as conn:
|
|
154
163
|
with conn:
|
|
@@ -156,7 +165,9 @@ def clear_history(filename=None) -> bool:
|
|
|
156
165
|
return True
|
|
157
166
|
|
|
158
167
|
|
|
159
|
-
def get_config(
|
|
168
|
+
def get_config(
|
|
169
|
+
key: str, default: Any = None, filename: str | Path | None = None
|
|
170
|
+
) -> Any:
|
|
160
171
|
initialise(filename)
|
|
161
172
|
with _get_connection(filename) as conn:
|
|
162
173
|
row = conn.execute(
|
|
@@ -170,7 +181,7 @@ def get_config(key: str, default=None, filename=None):
|
|
|
170
181
|
return row[0]
|
|
171
182
|
|
|
172
183
|
|
|
173
|
-
def set_config(key: str, value, filename=None) -> None:
|
|
184
|
+
def set_config(key: str, value: Any, filename: str | Path | None = None) -> None:
|
|
174
185
|
initialise(filename)
|
|
175
186
|
serialized = json.dumps(value)
|
|
176
187
|
with _get_connection(filename) as conn:
|
|
@@ -184,7 +195,7 @@ def set_config(key: str, value, filename=None) -> None:
|
|
|
184
195
|
)
|
|
185
196
|
|
|
186
197
|
|
|
187
|
-
def delete_config(key: str, filename=None) -> bool:
|
|
198
|
+
def delete_config(key: str, filename: str | Path | None = None) -> bool:
|
|
188
199
|
initialise(filename)
|
|
189
200
|
with _get_connection(filename) as conn:
|
|
190
201
|
with conn:
|
|
@@ -192,7 +203,7 @@ def delete_config(key: str, filename=None) -> bool:
|
|
|
192
203
|
return cursor.rowcount > 0
|
|
193
204
|
|
|
194
205
|
|
|
195
|
-
def register_plugin(plugin_name: str, filename=None) -> None:
|
|
206
|
+
def register_plugin(plugin_name: str, filename: str | Path | None = None) -> None:
|
|
196
207
|
initialise(filename)
|
|
197
208
|
now_utc = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
|
|
198
209
|
with _get_connection(filename) as conn:
|
|
@@ -206,7 +217,9 @@ def register_plugin(plugin_name: str, filename=None) -> None:
|
|
|
206
217
|
)
|
|
207
218
|
|
|
208
219
|
|
|
209
|
-
def get_plugin_data(
|
|
220
|
+
def get_plugin_data(
|
|
221
|
+
plugin_name: str, key: str, default: Any = None, filename: str | Path | None = None
|
|
222
|
+
) -> Any:
|
|
210
223
|
initialise(filename)
|
|
211
224
|
with _get_connection(filename) as conn:
|
|
212
225
|
row = conn.execute(
|
|
@@ -223,7 +236,9 @@ def get_plugin_data(plugin_name: str, key: str, default=None, filename=None):
|
|
|
223
236
|
return row[0]
|
|
224
237
|
|
|
225
238
|
|
|
226
|
-
def set_plugin_data(
|
|
239
|
+
def set_plugin_data(
|
|
240
|
+
plugin_name: str, key: str, value: Any, filename: str | Path | None = None
|
|
241
|
+
) -> None:
|
|
227
242
|
initialise(filename)
|
|
228
243
|
register_plugin(plugin_name, filename=filename)
|
|
229
244
|
serialized = json.dumps(value)
|
|
@@ -238,7 +253,7 @@ def set_plugin_data(plugin_name: str, key: str, value, filename=None) -> None:
|
|
|
238
253
|
)
|
|
239
254
|
|
|
240
255
|
|
|
241
|
-
def get_all_plugin_data(plugin_name: str, filename=None) -> dict:
|
|
256
|
+
def get_all_plugin_data(plugin_name: str, filename: str | Path | None = None) -> dict:
|
|
242
257
|
initialise(filename)
|
|
243
258
|
with _get_connection(filename) as conn:
|
|
244
259
|
rows = conn.execute(
|
|
@@ -253,7 +268,7 @@ def get_all_plugin_data(plugin_name: str, filename=None) -> dict:
|
|
|
253
268
|
return result
|
|
254
269
|
|
|
255
270
|
|
|
256
|
-
def purge_plugin(plugin_name: str, filename=None) -> bool:
|
|
271
|
+
def purge_plugin(plugin_name: str, filename: str | Path | None = None) -> bool:
|
|
257
272
|
initialise(filename)
|
|
258
273
|
with _get_connection(filename) as conn:
|
|
259
274
|
with conn:
|
|
@@ -263,7 +278,7 @@ def purge_plugin(plugin_name: str, filename=None) -> bool:
|
|
|
263
278
|
return cursor.rowcount > 0
|
|
264
279
|
|
|
265
280
|
|
|
266
|
-
def purge_all_plugin_data(filename=None) -> bool:
|
|
281
|
+
def purge_all_plugin_data(filename: str | Path | None = None) -> bool:
|
|
267
282
|
initialise(filename)
|
|
268
283
|
with _get_connection(filename) as conn:
|
|
269
284
|
with conn:
|
|
@@ -272,7 +287,9 @@ def purge_all_plugin_data(filename=None) -> bool:
|
|
|
272
287
|
return True
|
|
273
288
|
|
|
274
289
|
|
|
275
|
-
def delete_plugin_data(
|
|
290
|
+
def delete_plugin_data(
|
|
291
|
+
plugin_name: str, key: str, filename: str | Path | None = None
|
|
292
|
+
) -> bool:
|
|
276
293
|
initialise(filename)
|
|
277
294
|
with _get_connection(filename) as conn:
|
|
278
295
|
with conn:
|
|
@@ -22,7 +22,7 @@ class Cmds(BaseCmd):
|
|
|
22
22
|
options = None
|
|
23
23
|
aliases = ["help"]
|
|
24
24
|
|
|
25
|
-
def execute(self, args):
|
|
25
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
26
26
|
lines = ["\nAvailable Commands:"]
|
|
27
27
|
seen_cmds = set()
|
|
28
28
|
for cmd in COMMAND_REGISTRY.values():
|
|
@@ -87,7 +87,7 @@ for cmd_obj in INSTALLED_COMMANDS:
|
|
|
87
87
|
RESERVED_NAMES = set(COMMAND_REGISTRY.keys())
|
|
88
88
|
|
|
89
89
|
|
|
90
|
-
def log(cmd):
|
|
90
|
+
def log(cmd: str) -> None:
|
|
91
91
|
utc_now = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
92
92
|
data.append_history(cmd, utc_now)
|
|
93
93
|
|
|
@@ -284,7 +284,7 @@ def _parse_commands(raw_cmd: str) -> list:
|
|
|
284
284
|
return chain
|
|
285
285
|
|
|
286
286
|
|
|
287
|
-
def execute_line(raw_cmd: str):
|
|
287
|
+
def execute_line(raw_cmd: str) -> None:
|
|
288
288
|
chain = _parse_commands(raw_cmd)
|
|
289
289
|
if not chain:
|
|
290
290
|
return
|
|
@@ -75,7 +75,7 @@ class Cat(BaseCmd):
|
|
|
75
75
|
options = "Target file"
|
|
76
76
|
aliases = ["read"]
|
|
77
77
|
|
|
78
|
-
def execute(self, args):
|
|
78
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
79
79
|
show_numbers = ("-n" in args) or ("--number" in args)
|
|
80
80
|
limit = None
|
|
81
81
|
filtered_args = []
|
|
@@ -131,7 +131,7 @@ class Copy(BaseCmd):
|
|
|
131
131
|
options = "Source, then destination"
|
|
132
132
|
aliases = ["copy"]
|
|
133
133
|
|
|
134
|
-
def execute(self, args):
|
|
134
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
135
135
|
force = ("-f" in args) or ("--force" in args)
|
|
136
136
|
flags = {"-f", "--force"}
|
|
137
137
|
path_tokens = [arg for arg in args if arg not in flags]
|
|
@@ -185,7 +185,7 @@ class Dir(BaseCmd):
|
|
|
185
185
|
options = None
|
|
186
186
|
aliases = ["ls"]
|
|
187
187
|
|
|
188
|
-
def execute(self, args):
|
|
188
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
189
189
|
target_str = args[0].strip("\"'") if args else os.getcwd()
|
|
190
190
|
target_path = Path(target_str).expanduser().resolve()
|
|
191
191
|
if bridge.has_native_support() and hasattr(bridge._native, "dir"):
|
|
@@ -211,7 +211,7 @@ class Move(BaseCmd):
|
|
|
211
211
|
options = "Source, then destination"
|
|
212
212
|
aliases = ["move"]
|
|
213
213
|
|
|
214
|
-
def execute(self, args):
|
|
214
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
215
215
|
force = ("-f" in args) or ("--force" in args)
|
|
216
216
|
flags = {"-f", "--force"}
|
|
217
217
|
path_tokens = [arg for arg in args if arg not in flags]
|
|
@@ -276,7 +276,7 @@ class MkDir(BaseCmd):
|
|
|
276
276
|
options = "Directory name"
|
|
277
277
|
aliases = ["md"]
|
|
278
278
|
|
|
279
|
-
def execute(self, args):
|
|
279
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
280
280
|
use_parents = ("-p" in args) or ("--parents" in args)
|
|
281
281
|
path_tokens = [arg for arg in args if arg not in ("-p", "--parents")]
|
|
282
282
|
if not path_tokens:
|
|
@@ -304,7 +304,7 @@ class Rename(BaseCmd):
|
|
|
304
304
|
options = "Old name, then new name"
|
|
305
305
|
aliases = []
|
|
306
306
|
|
|
307
|
-
def execute(self, args):
|
|
307
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
308
308
|
raw_src = args[0].strip("\"'")
|
|
309
309
|
raw_new_name = args[1].strip("\"'")
|
|
310
310
|
if raw_new_name in (".", "..") or "/" in raw_new_name or "\\" in raw_new_name:
|
|
@@ -346,7 +346,7 @@ class Rm(BaseCmd):
|
|
|
346
346
|
options = "Target file"
|
|
347
347
|
aliases = ["del"]
|
|
348
348
|
|
|
349
|
-
def execute(self, args):
|
|
349
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
350
350
|
force = ("-f" in args) or ("--force" in args)
|
|
351
351
|
recursive = ("-r" in args) or ("--recursive" in args)
|
|
352
352
|
flags = {"-f", "--force", "-r", "--recursive"}
|
|
@@ -397,7 +397,7 @@ class RmDir(BaseCmd):
|
|
|
397
397
|
options = "Target directory"
|
|
398
398
|
aliases = []
|
|
399
399
|
|
|
400
|
-
def execute(self, args):
|
|
400
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
401
401
|
force = ("-f" in args) or ("--force" in args)
|
|
402
402
|
path_tokens = [arg for arg in args if arg not in ("-f", "--force")]
|
|
403
403
|
if not path_tokens:
|
|
@@ -430,7 +430,7 @@ class Touch(BaseCmd):
|
|
|
430
430
|
min_args = 1
|
|
431
431
|
options = "Target file"
|
|
432
432
|
|
|
433
|
-
def execute(self, args):
|
|
433
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
434
434
|
if not args:
|
|
435
435
|
return (1, "\nCommand Error: Target file not specified.\n")
|
|
436
436
|
raw_target = " ".join(args).strip("\"'")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# src/flyshell/startup/deps.py
|
|
2
2
|
|
|
3
|
-
from typing import List, Tuple
|
|
3
|
+
from typing import Any, List, Tuple
|
|
4
4
|
import importlib.util
|
|
5
5
|
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ def check_module_installed(module_name: str) -> bool:
|
|
|
12
12
|
return False
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
def verify_plugin_dependencies(plugin) -> Tuple[List[str], List[str]]:
|
|
15
|
+
def verify_plugin_dependencies(plugin: Any) -> Tuple[List[str], List[str]]:
|
|
16
16
|
declared = getattr(plugin, "third_pty_libs", None) or []
|
|
17
17
|
installed = []
|
|
18
18
|
missing = []
|
|
@@ -14,7 +14,7 @@ def get_env_path() -> Path:
|
|
|
14
14
|
return primary
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
def create_env():
|
|
17
|
+
def create_env() -> None:
|
|
18
18
|
env_path = get_env_path()
|
|
19
19
|
if not env_path.exists():
|
|
20
20
|
env_path.touch()
|
|
@@ -98,7 +98,7 @@ def get_plugin_api_keys(plugin_name_or_dir: str) -> dict[str, str]:
|
|
|
98
98
|
def get_all_keys() -> tuple[int, str]:
|
|
99
99
|
env_path = get_env_path()
|
|
100
100
|
if not env_path.exists():
|
|
101
|
-
return (1, f"File Config Error: Environment file not found at '{env_path}'
|
|
101
|
+
return (1, f"File Config Error: Environment file not found at '{env_path}'")
|
|
102
102
|
try:
|
|
103
103
|
all_env = read_env_file()
|
|
104
104
|
if not all_env:
|
|
@@ -116,7 +116,7 @@ def get_plugin_keys_formatted(target_name: str) -> tuple[int, str]:
|
|
|
116
116
|
return (1, "Command Error: A valid plugin name must be provided.")
|
|
117
117
|
env_path = get_env_path()
|
|
118
118
|
if not env_path.exists():
|
|
119
|
-
return (1, f"File Config Error: Environment file not found at '{env_path}'
|
|
119
|
+
return (1, f"File Config Error: Environment file not found at '{env_path}'")
|
|
120
120
|
dir_name, plugin = _resolve_plugin_dir_name(target_name)
|
|
121
121
|
configured_keys = get_plugin_api_keys(target_name)
|
|
122
122
|
required_keys = (getattr(plugin, "api_keys", None) or []) if plugin else []
|
|
@@ -13,7 +13,7 @@ import inspect
|
|
|
13
13
|
import sys
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
def scan_plugins(plugin_folder=None):
|
|
16
|
+
def scan_plugins(plugin_folder: str | Path | None = None) -> None:
|
|
17
17
|
folder = Path(plugin_folder) if plugin_folder else c.USER_PLUGIN_DIR
|
|
18
18
|
c.PLUGINS.clear()
|
|
19
19
|
if not folder.exists():
|
|
@@ -62,21 +62,6 @@ def scan_plugins(plugin_folder=None):
|
|
|
62
62
|
)
|
|
63
63
|
break
|
|
64
64
|
ctx = build_context(resolved_name, default_name, file_path)
|
|
65
|
-
required_keys = getattr(obj, "api_keys", None) or []
|
|
66
|
-
found_keys = ctx["api_keys"]
|
|
67
|
-
found_keys_lower = {k.lower(): v for k, v in found_keys.items()}
|
|
68
|
-
missing_keys = [
|
|
69
|
-
k for k in required_keys if k.lower() not in found_keys_lower
|
|
70
|
-
]
|
|
71
|
-
if missing_keys:
|
|
72
|
-
env_file = ctx["env_path"]
|
|
73
|
-
print(
|
|
74
|
-
f"\n⚠️ API Key Error - Plugin '{resolved_name}' is missing required key(s): {', '.join(missing_keys)}"
|
|
75
|
-
)
|
|
76
|
-
print(f"Please define them in: {env_file} as:")
|
|
77
|
-
for mk in missing_keys:
|
|
78
|
-
print(f"{default_name}_{mk}=<your_key>")
|
|
79
|
-
print("You can do this once Flyshell has booted.")
|
|
80
65
|
candidates.setdefault(resolved_name, []).append(
|
|
81
66
|
(obj, ctx, file_path)
|
|
82
67
|
)
|
|
@@ -115,7 +100,9 @@ def scan_plugins(plugin_folder=None):
|
|
|
115
100
|
print("\nNo plugins loaded.")
|
|
116
101
|
|
|
117
102
|
|
|
118
|
-
def build_context(
|
|
103
|
+
def build_context(
|
|
104
|
+
plugin_name: str, default_name: str, file_path: str | Path | None = None
|
|
105
|
+
) -> dict:
|
|
119
106
|
plugin_storage = data.get_all_plugin_data(plugin_name)
|
|
120
107
|
api_keys = env.get_plugin_api_keys(str(default_name))
|
|
121
108
|
context = {
|
|
@@ -130,7 +117,7 @@ def build_context(plugin_name, default_name, file_path=None) -> dict:
|
|
|
130
117
|
return context
|
|
131
118
|
|
|
132
119
|
|
|
133
|
-
def check_plugin_api_keys():
|
|
120
|
+
def check_plugin_api_keys() -> None:
|
|
134
121
|
if not c.PLUGINS:
|
|
135
122
|
return
|
|
136
123
|
print("\nFlyshell will now check plugin API keys.")
|
|
@@ -186,7 +173,7 @@ def check_all_plugin_dependencies() -> Dict[str, List[str]]:
|
|
|
186
173
|
return all_missing
|
|
187
174
|
|
|
188
175
|
|
|
189
|
-
def unload_plugins():
|
|
176
|
+
def unload_plugins() -> None:
|
|
190
177
|
for identifier, plugin in list(c.PLUGINS.items()):
|
|
191
178
|
try:
|
|
192
179
|
if hasattr(plugin, "on_unload"):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flyshell
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.0
|
|
4
4
|
Summary: A modular, zero-dependency command-line environment in Python.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -23,7 +23,7 @@ Dynamic: license-file
|
|
|
23
23
|

|
|
24
24
|

|
|
25
25
|
|
|
26
|
-
> Documentation last updated: v1.
|
|
26
|
+
> Documentation last updated: v1.6.0
|
|
27
27
|
|
|
28
28
|
A modular, zero-dependency command-line environment and extensible runtime interface built in Python with compiled C-extensions.
|
|
29
29
|
|
|
@@ -38,7 +38,7 @@ No extra packages required, just install and enjoy!
|
|
|
38
38
|
3. **Secure Authentication**: Flyshell uses salted PBKDF2 HMAC (SHA-256, 600,000 iterations) with constant-time equality comparisons to prevent timing attacks on password information.
|
|
39
39
|
4. **Cross-Platform Support**: Flyshell is fully supported by Windows (NT), macOS (Darwin) and Linux installations with native OS management and POSIX-aware parsing. Note that Flyshell is **not** supported by any other systems.
|
|
40
40
|
5. **State and History Persistence**: Flyshell has a fully encapsulated SQL storage system using SQLite3 providing session metrics and ISO 8601 UTC audit logging.
|
|
41
|
-
6. **Automatic C-Extension Compilation**: If installed via `pip` on Windows or Linux, Flyshell is shipped with pre-compiled wheels. For macOS users, Xcode CLI
|
|
41
|
+
6. **Automatic C-Extension Compilation**: If installed via `pip` on Windows or Linux, Flyshell is shipped with pre-compiled wheels. For macOS users, Xcode CLI Tools is required as macOS builds install from source.
|
|
42
42
|
|
|
43
43
|
## System Requirements
|
|
44
44
|
|
|
@@ -67,24 +67,6 @@ def test_loader_populates_context_correctly(tmp_path, mock_env_file, monkeypatch
|
|
|
67
67
|
assert plugin.get_api_key("token") == "token123"
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
def test_loader_rejects_plugin_with_missing_keys(
|
|
71
|
-
tmp_path, mock_env_file, monkeypatch, capsys
|
|
72
|
-
):
|
|
73
|
-
mock_env_file.write_text("needkey_first=val1\n")
|
|
74
|
-
plugin_file = tmp_path / "needkey.py"
|
|
75
|
-
plugin_file.write_text(
|
|
76
|
-
"from flyshell.abstract.base_plugin import BasePlugin\n"
|
|
77
|
-
"class NeedKeyPlugin(BasePlugin):\n"
|
|
78
|
-
" api_keys = ['first', 'second']\n"
|
|
79
|
-
" def execute(self, args): return 0\n"
|
|
80
|
-
)
|
|
81
|
-
monkeypatch.setattr(c, "USER_PLUGIN_DIR", tmp_path)
|
|
82
|
-
loader.scan_plugins(plugin_folder=tmp_path)
|
|
83
|
-
out = capsys.readouterr().out
|
|
84
|
-
assert "API Key Error" in out
|
|
85
|
-
assert "second" in out
|
|
86
|
-
|
|
87
|
-
|
|
88
70
|
def test_directory_execute_fallback_when_keys_missing(
|
|
89
71
|
mock_env_file, monkeypatch, capsys
|
|
90
72
|
):
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# tests/test_security.py
|
|
2
|
-
|
|
3
|
-
from flyshell.builtin import system
|
|
4
|
-
from flyshell.accounts import auth
|
|
5
|
-
from flyshell.core import data
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def test_sysexe_blocks_prohibited_base_commands():
|
|
9
|
-
for cmd in ["format C:", "diskpart", "dd if=/dev/zero"]:
|
|
10
|
-
tokens = cmd.split()
|
|
11
|
-
code, message = system.SysExe().execute(tokens)
|
|
12
|
-
assert code == 1
|
|
13
|
-
assert "Security Error" in message
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def test_sysexe_dangerous_commands_require_auth(monkeypatch):
|
|
17
|
-
dummy_hash, dummy_salt = auth.hash_password("ValidPassword123!")
|
|
18
|
-
monkeypatch.setattr(
|
|
19
|
-
data,
|
|
20
|
-
"get_auth",
|
|
21
|
-
lambda: {"username": "TestUser", "hash": dummy_hash, "salt": dummy_salt},
|
|
22
|
-
)
|
|
23
|
-
monkeypatch.setattr("getpass.getpass", lambda prompt="": "WrongPassword")
|
|
24
|
-
for cmd in ["del some_file.txt", "rm -rf some_dir"]:
|
|
25
|
-
tokens = cmd.split()
|
|
26
|
-
code, message = system.SysExe().execute(tokens)
|
|
27
|
-
assert code == 1
|
|
28
|
-
assert "Account Error" in message or "Password does not match" in message
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def test_sysexe_force_flag_without_arguments_returns_error():
|
|
32
|
-
code, message = system.SysExe().execute(["-f"])
|
|
33
|
-
assert code == 1
|
|
34
|
-
assert "requires at least 1 parameter" in message
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def test_sysexe_blocks_command_with_path_or_extension():
|
|
38
|
-
for cmd in ["/bin/dd if=/dev/zero", "diskpart.exe", "format.com"]:
|
|
39
|
-
tokens = cmd.split()
|
|
40
|
-
code, message = system.SysExe().execute(tokens)
|
|
41
|
-
assert code == 1
|
|
42
|
-
assert "Security Error" in message
|
|
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
|
|
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
|