flyshell 1.6.3__tar.gz → 1.6.4__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.6.3/src/flyshell.egg-info → flyshell-1.6.4}/PKG-INFO +1 -1
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/__init__.py +4 -2
- flyshell-1.6.4/src/flyshell/abstract/__init__.py +11 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/accounts/auth.py +1 -2
- flyshell-1.6.4/src/flyshell/builtin/__init__.py +21 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/builtin/fs.py +1 -3
- flyshell-1.6.4/src/flyshell/builtin/lifecycle.py +76 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/builtin/pkg.py +1 -3
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/builtin/system.py +1 -1
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/builtin/utils.py +1 -73
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/constants.py +7 -4
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/core/directory.py +21 -25
- flyshell-1.6.4/src/flyshell/native/__init__.py +19 -0
- flyshell-1.6.4/src/flyshell/native/diskops_guard.py +71 -0
- flyshell-1.6.4/src/flyshell/native/diskops_read.py +138 -0
- flyshell-1.6.3/src/flyshell/native/diskops_handler.py → flyshell-1.6.4/src/flyshell/native/diskops_write.py +11 -219
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/pkgm/loader.py +1 -2
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/startup/checks.py +2 -2
- {flyshell-1.6.3 → flyshell-1.6.4/src/flyshell.egg-info}/PKG-INFO +1 -1
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell.egg-info/SOURCES.txt +4 -1
- {flyshell-1.6.3 → flyshell-1.6.4}/tests/test_diskops_ext.py +35 -37
- {flyshell-1.6.3 → flyshell-1.6.4}/tests/test_diskops_lgc.py +25 -25
- {flyshell-1.6.3 → flyshell-1.6.4}/tests/test_env.py +1 -2
- {flyshell-1.6.3 → flyshell-1.6.4}/tests/test_fs.py +7 -7
- {flyshell-1.6.3 → flyshell-1.6.4}/tests/test_loader.py +5 -6
- {flyshell-1.6.3 → flyshell-1.6.4}/tests/test_pkg.py +5 -5
- {flyshell-1.6.3 → flyshell-1.6.4}/tests/test_utils.py +9 -10
- flyshell-1.6.3/src/flyshell/core/__init__.py +0 -0
- flyshell-1.6.3/src/flyshell/native/__init__.py +0 -0
- flyshell-1.6.3/src/flyshell/native/legacy/__init__.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/LICENSE +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/MANIFEST.in +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/README.md +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/diskops.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/posix/cat.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/posix/cp.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/posix/dir.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/posix/mkdir.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/posix/mv.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/posix/rename.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/posix/rm.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/posix/rmdir.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/posix/touch.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/shared/dir_types.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/shared/dir_types.h +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/shared/native_errors.h +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/shared/win32_utf.h +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/win32/cat.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/win32/cp.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/win32/dir.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/win32/mkdir.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/win32/mv.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/win32/rename.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/win32/rm.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/win32/rmdir.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/c_src/diskops/win32/touch.c +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/pyproject.toml +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/setup.cfg +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/setup.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/abstract/base_cmd.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/abstract/base_plugin.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/abstract/parent_cmd.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/accounts/__init__.py +0 -0
- {flyshell-1.6.3/src/flyshell/abstract → flyshell-1.6.4/src/flyshell/bin}/__init__.py +0 -0
- {flyshell-1.6.3/src/flyshell/bin → flyshell-1.6.4/src/flyshell/core}/__init__.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/core/console.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/data/__init__.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/data/auth.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/data/config.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/data/db_manager.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/data/env.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/data/history.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/data/plugins.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/main.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/misc/__init__.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/misc/seasonal.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/native/diskops_bridge.py +0 -0
- {flyshell-1.6.3/src/flyshell/builtin → flyshell-1.6.4/src/flyshell/native/legacy}/__init__.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/native/legacy/diskops.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/pkgm/__init__.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/pkgm/inspection.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/pkgm/keys.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/startup/__init__.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell/startup/boot.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell.egg-info/dependency_links.txt +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell.egg-info/entry_points.txt +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell.egg-info/requires.txt +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/src/flyshell.egg-info/top_level.txt +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/tests/test_auth.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/tests/test_data.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/tests/test_deps.py +0 -0
- {flyshell-1.6.3 → flyshell-1.6.4}/tests/test_directory.py +0 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# src/flyshell/__init__.py
|
|
2
2
|
|
|
3
3
|
try:
|
|
4
|
-
from flyshell.abstract
|
|
4
|
+
from flyshell.abstract import BaseCmd, BasePlugin, ParentCmd
|
|
5
5
|
|
|
6
|
-
__all__ = ["BasePlugin"]
|
|
6
|
+
__all__ = ["BaseCmd", "BasePlugin", "ParentCmd"]
|
|
7
7
|
except ImportError:
|
|
8
|
+
BaseCmd = None
|
|
8
9
|
BasePlugin = None
|
|
10
|
+
ParentCmd = None
|
|
9
11
|
__all__ = []
|
|
10
12
|
|
|
11
13
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# src/flyshell/abstract/__init__.py
|
|
2
|
+
|
|
3
|
+
from flyshell.abstract.base_cmd import BaseCmd
|
|
4
|
+
from flyshell.abstract.base_plugin import BasePlugin
|
|
5
|
+
from flyshell.abstract.parent_cmd import ParentCmd
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"BaseCmd",
|
|
9
|
+
"BasePlugin",
|
|
10
|
+
"ParentCmd",
|
|
11
|
+
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# src/flyshell/builtin/__init__.py
|
|
2
|
+
|
|
3
|
+
from flyshell.builtin.fs import Fs
|
|
4
|
+
from flyshell.builtin.lifecycle import Kill, Reboot, Sleep
|
|
5
|
+
from flyshell.builtin.pkg import Pkg
|
|
6
|
+
from flyshell.builtin.system import Cd, OpenFile, SysExe
|
|
7
|
+
from flyshell.builtin.utils import Clear, Echo, History
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"Cd",
|
|
11
|
+
"Clear",
|
|
12
|
+
"Echo",
|
|
13
|
+
"Fs",
|
|
14
|
+
"History",
|
|
15
|
+
"Kill",
|
|
16
|
+
"OpenFile",
|
|
17
|
+
"Pkg",
|
|
18
|
+
"Reboot",
|
|
19
|
+
"Sleep",
|
|
20
|
+
"SysExe",
|
|
21
|
+
]
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
# src/flyshell/builtin/fs.py
|
|
2
2
|
|
|
3
3
|
from flyshell import constants as c
|
|
4
|
-
from flyshell import data, misc
|
|
5
|
-
from flyshell.abstract.base_cmd import BaseCmd
|
|
6
|
-
from flyshell.abstract.parent_cmd import ParentCmd
|
|
4
|
+
from flyshell import BaseCmd, ParentCmd, data, misc
|
|
7
5
|
|
|
8
6
|
import os
|
|
9
7
|
import sys
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# src/flyshell/builtin/lifecycle.py
|
|
2
|
+
|
|
3
|
+
from flyshell import constants as c
|
|
4
|
+
from flyshell import BaseCmd
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import signal
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
import time
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Kill(BaseCmd):
|
|
14
|
+
name = "kill"
|
|
15
|
+
description = "Shut down the Flyshell system"
|
|
16
|
+
min_args = 0
|
|
17
|
+
options = None
|
|
18
|
+
aliases = []
|
|
19
|
+
|
|
20
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
21
|
+
choice = input("\nAre you sure [y/n]?: ").strip().lower()
|
|
22
|
+
if choice == "y":
|
|
23
|
+
return (-1, "\nShutting down...\n")
|
|
24
|
+
return (1, "\nAction cancelled.\n")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Reboot(BaseCmd):
|
|
28
|
+
name = "reboot"
|
|
29
|
+
description = "Reboot the Flyshell system"
|
|
30
|
+
min_args = 0
|
|
31
|
+
options = None
|
|
32
|
+
aliases = ["restart"]
|
|
33
|
+
|
|
34
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
35
|
+
print("\nRestarting Flyshell...\n")
|
|
36
|
+
is_direct_script = (
|
|
37
|
+
sys.argv[0].lower().endswith(".exe")
|
|
38
|
+
or os.path.basename(sys.argv[0]) == "flyshell"
|
|
39
|
+
)
|
|
40
|
+
if is_direct_script:
|
|
41
|
+
cmd = sys.argv
|
|
42
|
+
else:
|
|
43
|
+
cmd = [sys.executable] + sys.argv
|
|
44
|
+
if c.HOST_OS == "Windows":
|
|
45
|
+
old_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
|
|
46
|
+
try:
|
|
47
|
+
p = subprocess.run(cmd)
|
|
48
|
+
sys.exit(p.returncode)
|
|
49
|
+
finally:
|
|
50
|
+
signal.signal(signal.SIGINT, old_handler)
|
|
51
|
+
else:
|
|
52
|
+
os.execv(cmd[0], cmd)
|
|
53
|
+
return (0, "")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class Sleep(BaseCmd):
|
|
57
|
+
name = "sleep"
|
|
58
|
+
description = "Sleep the system for a specified time"
|
|
59
|
+
min_args = 1
|
|
60
|
+
options = "Duration (secs)"
|
|
61
|
+
aliases = []
|
|
62
|
+
|
|
63
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
64
|
+
if not args or not args[0].replace(".", "", 1).isdigit():
|
|
65
|
+
return (
|
|
66
|
+
1,
|
|
67
|
+
f"\nCommand Error: Invalid argument '{args[0] if args else ''}'\n",
|
|
68
|
+
)
|
|
69
|
+
secs = float(args[0])
|
|
70
|
+
try:
|
|
71
|
+
print(f"\nPausing Flyshell for {secs} second(s).")
|
|
72
|
+
print("Press Ctrl+C to cancel.\n")
|
|
73
|
+
time.sleep(secs)
|
|
74
|
+
return (0, "\nReturning...\n")
|
|
75
|
+
except KeyboardInterrupt:
|
|
76
|
+
return (1, "\nSleep cancelled.\n")
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
# src/flyshell/builtin/pkg.py
|
|
2
2
|
|
|
3
3
|
from typing import List, Tuple
|
|
4
|
-
from flyshell import pkgm
|
|
5
|
-
from flyshell.abstract.base_cmd import BaseCmd
|
|
6
|
-
from flyshell.abstract.parent_cmd import ParentCmd
|
|
4
|
+
from flyshell import BaseCmd, ParentCmd, pkgm
|
|
7
5
|
|
|
8
6
|
|
|
9
7
|
class PkgApi(BaseCmd):
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
# src/flyshell/builtin/utils.py
|
|
2
2
|
|
|
3
3
|
from flyshell import constants as c
|
|
4
|
-
from flyshell import data
|
|
5
|
-
from flyshell.abstract.base_cmd import BaseCmd
|
|
4
|
+
from flyshell import BaseCmd, data
|
|
6
5
|
|
|
7
6
|
import codecs
|
|
8
|
-
import os
|
|
9
7
|
import re
|
|
10
|
-
import signal
|
|
11
|
-
import subprocess
|
|
12
|
-
import sys
|
|
13
|
-
import time
|
|
14
8
|
|
|
15
9
|
|
|
16
10
|
class Clear(BaseCmd):
|
|
@@ -81,69 +75,3 @@ class History(BaseCmd):
|
|
|
81
75
|
lines.append(f"#{i}: {cmd} [at {date_part} @ {time_part} UTC]")
|
|
82
76
|
lines.append("")
|
|
83
77
|
return (0, "\n".join(lines))
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
class Kill(BaseCmd):
|
|
87
|
-
name = "kill"
|
|
88
|
-
description = "Shut down the Flyshell system"
|
|
89
|
-
min_args = 0
|
|
90
|
-
options = None
|
|
91
|
-
aliases = []
|
|
92
|
-
|
|
93
|
-
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
94
|
-
choice = input("\nAre you sure [y/n]?: ").strip().lower()
|
|
95
|
-
if choice == "y":
|
|
96
|
-
return (-1, "\nShutting down...\n")
|
|
97
|
-
return (1, "\nAction cancelled.\n")
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
class Reboot(BaseCmd):
|
|
101
|
-
name = "reboot"
|
|
102
|
-
description = "Reboot the Flyshell system"
|
|
103
|
-
min_args = 0
|
|
104
|
-
options = None
|
|
105
|
-
aliases = ["restart"]
|
|
106
|
-
|
|
107
|
-
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
108
|
-
print("\nRestarting Flyshell...\n")
|
|
109
|
-
is_direct_script = (
|
|
110
|
-
sys.argv[0].lower().endswith(".exe")
|
|
111
|
-
or os.path.basename(sys.argv[0]) == "flyshell"
|
|
112
|
-
)
|
|
113
|
-
if is_direct_script:
|
|
114
|
-
cmd = sys.argv
|
|
115
|
-
else:
|
|
116
|
-
cmd = [sys.executable] + sys.argv
|
|
117
|
-
if c.HOST_OS == "Windows":
|
|
118
|
-
old_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
|
|
119
|
-
try:
|
|
120
|
-
p = subprocess.run(cmd)
|
|
121
|
-
sys.exit(p.returncode)
|
|
122
|
-
finally:
|
|
123
|
-
signal.signal(signal.SIGINT, old_handler)
|
|
124
|
-
else:
|
|
125
|
-
os.execv(cmd[0], cmd)
|
|
126
|
-
return (0, "")
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
class Sleep(BaseCmd):
|
|
130
|
-
name = "sleep"
|
|
131
|
-
description = "Sleep the system for a specified time"
|
|
132
|
-
min_args = 1
|
|
133
|
-
options = "Duration (secs)"
|
|
134
|
-
aliases = []
|
|
135
|
-
|
|
136
|
-
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
137
|
-
if not args or not args[0].replace(".", "", 1).isdigit():
|
|
138
|
-
return (
|
|
139
|
-
1,
|
|
140
|
-
f"\nCommand Error: Invalid argument '{args[0] if args else ''}'\n",
|
|
141
|
-
)
|
|
142
|
-
secs = float(args[0])
|
|
143
|
-
try:
|
|
144
|
-
print(f"\nPausing Flyshell for {secs} second(s).")
|
|
145
|
-
print("Press Ctrl+C to cancel.\n")
|
|
146
|
-
time.sleep(secs)
|
|
147
|
-
return (0, "\nReturning...\n")
|
|
148
|
-
except KeyboardInterrupt:
|
|
149
|
-
return (1, "\nSleep cancelled.\n")
|
|
@@ -5,9 +5,9 @@ import os
|
|
|
5
5
|
import platform
|
|
6
6
|
import time
|
|
7
7
|
|
|
8
|
-
BUILD =
|
|
9
|
-
VERFULL = "1.6.
|
|
10
|
-
VERSION = "1.6.
|
|
8
|
+
BUILD = 224
|
|
9
|
+
VERFULL = "1.6.4e"
|
|
10
|
+
VERSION = "1.6.4"
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def _resolve_app_dir() -> Path:
|
|
@@ -58,6 +58,7 @@ REQUIRED_COMPONENTS = [
|
|
|
58
58
|
"builtin",
|
|
59
59
|
"builtin/__init__.py",
|
|
60
60
|
"builtin/fs.py",
|
|
61
|
+
"builtin/lifecycle.py",
|
|
61
62
|
"builtin/pkg.py",
|
|
62
63
|
"builtin/system.py",
|
|
63
64
|
"builtin/utils.py",
|
|
@@ -84,7 +85,9 @@ REQUIRED_COMPONENTS = [
|
|
|
84
85
|
"native/legacy/__init__.py",
|
|
85
86
|
"native/legacy/diskops.py",
|
|
86
87
|
"native/diskops_bridge.py",
|
|
87
|
-
"native/
|
|
88
|
+
"native/diskops_guard.py",
|
|
89
|
+
"native/diskops_read.py",
|
|
90
|
+
"native/diskops_write.py",
|
|
88
91
|
"pkgm",
|
|
89
92
|
"pkgm/__init__.py",
|
|
90
93
|
"pkgm/inspection.py",
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
# src/flyshell/core/directory.py
|
|
2
2
|
|
|
3
3
|
from flyshell import constants as c
|
|
4
|
-
from flyshell import accounts, data, pkgm
|
|
5
|
-
from flyshell.abstract.base_cmd import BaseCmd
|
|
6
|
-
from flyshell.abstract.parent_cmd import ParentCmd
|
|
7
|
-
from flyshell.builtin import fs, pkg, system, utils
|
|
8
|
-
from flyshell.native import diskops_handler as diskops
|
|
4
|
+
from flyshell import BaseCmd, ParentCmd, accounts, builtin, data, native, pkgm
|
|
9
5
|
|
|
10
6
|
from datetime import datetime, timezone
|
|
11
7
|
import copy
|
|
@@ -52,28 +48,28 @@ class Cmds(BaseCmd):
|
|
|
52
48
|
|
|
53
49
|
|
|
54
50
|
INSTALLED_COMMANDS: list[BaseCmd] = [
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
native.Cat(),
|
|
52
|
+
builtin.Cd(),
|
|
57
53
|
Cmds(),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
builtin.Clear(),
|
|
55
|
+
native.Copy(),
|
|
56
|
+
native.Dir(),
|
|
57
|
+
builtin.Echo(),
|
|
58
|
+
builtin.Fs(),
|
|
59
|
+
builtin.History(),
|
|
60
|
+
builtin.Kill(),
|
|
65
61
|
accounts.Lock(),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
62
|
+
native.MkDir(),
|
|
63
|
+
native.Move(),
|
|
64
|
+
builtin.OpenFile(),
|
|
65
|
+
builtin.Pkg(),
|
|
66
|
+
builtin.Reboot(),
|
|
67
|
+
native.Rename(),
|
|
68
|
+
native.Rm(),
|
|
69
|
+
native.RmDir(),
|
|
70
|
+
builtin.Sleep(),
|
|
71
|
+
builtin.SysExe(),
|
|
72
|
+
native.Touch(),
|
|
77
73
|
]
|
|
78
74
|
|
|
79
75
|
COMMAND_REGISTRY: dict[str, BaseCmd] = {}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# src/flyshell/native/__init__.py
|
|
2
|
+
|
|
3
|
+
from flyshell.native.diskops_bridge import has_native_support, translate_error
|
|
4
|
+
from flyshell.native.diskops_read import Cat, Dir, MkDir, Touch
|
|
5
|
+
from flyshell.native.diskops_write import Copy, Move, Rename, Rm, RmDir
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"Cat",
|
|
9
|
+
"Copy",
|
|
10
|
+
"Dir",
|
|
11
|
+
"MkDir",
|
|
12
|
+
"Move",
|
|
13
|
+
"Rename",
|
|
14
|
+
"Rm",
|
|
15
|
+
"RmDir",
|
|
16
|
+
"Touch",
|
|
17
|
+
"has_native_support",
|
|
18
|
+
"translate_error",
|
|
19
|
+
]
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# src/flyshell/native/diskops_guard.py
|
|
2
|
+
|
|
3
|
+
from flyshell import constants as c
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def validate_flyshell_target(
|
|
10
|
+
target_path: Path, raw_target: str, label: str = "Target"
|
|
11
|
+
) -> tuple[int, str] | None:
|
|
12
|
+
flyshell_dirs = [
|
|
13
|
+
c.APP_DIR.resolve(),
|
|
14
|
+
c.PACKAGE_ROOT.resolve(),
|
|
15
|
+
c.PROJECT_ROOT.resolve(),
|
|
16
|
+
]
|
|
17
|
+
for protected in flyshell_dirs:
|
|
18
|
+
if target_path == protected or target_path.is_relative_to(protected):
|
|
19
|
+
return (
|
|
20
|
+
1,
|
|
21
|
+
"\nSecurity Error: Flyshell has blocked this action.\n"
|
|
22
|
+
f"{label} '{raw_target}' contains or belongs to Flyshell system files.\n"
|
|
23
|
+
"If you wish to delete Flyshell, use the host.\n",
|
|
24
|
+
)
|
|
25
|
+
return None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def validate_delete_target(
|
|
29
|
+
target_path: Path, raw_target: str
|
|
30
|
+
) -> tuple[int, str] | None:
|
|
31
|
+
if target_path == target_path.parent or str(target_path) == target_path.anchor:
|
|
32
|
+
return (
|
|
33
|
+
1,
|
|
34
|
+
"\nSecurity Error: Flyshell has blocked this action.\n"
|
|
35
|
+
"You cannot delete the root filesystem directory.\n",
|
|
36
|
+
)
|
|
37
|
+
critical_system_dirs = [
|
|
38
|
+
Path.home().parent.resolve(),
|
|
39
|
+
Path.home().resolve(),
|
|
40
|
+
]
|
|
41
|
+
if c.HOST_OS == "Windows":
|
|
42
|
+
system_drive = os.environ.get("SystemDrive", "C:")
|
|
43
|
+
critical_system_dirs.extend(
|
|
44
|
+
[
|
|
45
|
+
Path(f"{system_drive}\\Windows").resolve(),
|
|
46
|
+
Path(f"{system_drive}\\Program Files").resolve(),
|
|
47
|
+
Path(f"{system_drive}\\Program Files (x86)").resolve(),
|
|
48
|
+
]
|
|
49
|
+
)
|
|
50
|
+
else:
|
|
51
|
+
critical_system_dirs.extend(
|
|
52
|
+
[
|
|
53
|
+
Path("/bin").resolve(),
|
|
54
|
+
Path("/etc").resolve(),
|
|
55
|
+
Path("/usr").resolve(),
|
|
56
|
+
Path("/var").resolve(),
|
|
57
|
+
]
|
|
58
|
+
)
|
|
59
|
+
if target_path in critical_system_dirs:
|
|
60
|
+
return (
|
|
61
|
+
1,
|
|
62
|
+
"\nSecurity Error: Flyshell has blocked this action.\n"
|
|
63
|
+
f"Target '{raw_target}' is a protected operating system directory.\n",
|
|
64
|
+
)
|
|
65
|
+
if target_path == Path(os.getcwd()).resolve():
|
|
66
|
+
return (
|
|
67
|
+
1,
|
|
68
|
+
"\nSystem Error: Cannot remove current working directory.\n"
|
|
69
|
+
"Switch to a different directory using 'cd' first.\n",
|
|
70
|
+
)
|
|
71
|
+
return validate_flyshell_target(target_path, raw_target)
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# src/flyshell/native/diskops_read.py
|
|
2
|
+
|
|
3
|
+
from flyshell import BaseCmd
|
|
4
|
+
from flyshell.native import diskops_bridge as bridge
|
|
5
|
+
from flyshell.native.legacy import diskops as legacy
|
|
6
|
+
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import os
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Cat(BaseCmd):
|
|
12
|
+
name = "cat"
|
|
13
|
+
description = "Display the contents of a text file"
|
|
14
|
+
min_args = 1
|
|
15
|
+
options = "Target file"
|
|
16
|
+
aliases = ["read"]
|
|
17
|
+
|
|
18
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
19
|
+
show_numbers = ("-n" in args) or ("--number" in args)
|
|
20
|
+
limit = None
|
|
21
|
+
filtered_args = []
|
|
22
|
+
skip_next = False
|
|
23
|
+
for i, token in enumerate(args):
|
|
24
|
+
if skip_next:
|
|
25
|
+
skip_next = False
|
|
26
|
+
continue
|
|
27
|
+
if token in ("-n", "--number"):
|
|
28
|
+
continue
|
|
29
|
+
if token in ("-l", "--limit"):
|
|
30
|
+
if i + 1 < len(args) and args[i + 1].isdigit():
|
|
31
|
+
limit = int(args[i + 1])
|
|
32
|
+
skip_next = True
|
|
33
|
+
continue
|
|
34
|
+
else:
|
|
35
|
+
return (
|
|
36
|
+
1,
|
|
37
|
+
f"\nCommand Error: '{token}' requires a positive integer limit.\n",
|
|
38
|
+
)
|
|
39
|
+
filtered_args.append(token)
|
|
40
|
+
if not filtered_args:
|
|
41
|
+
return (1, "\nCommand Error: Target file not specified.\n")
|
|
42
|
+
raw_target = " ".join(filtered_args).strip("\"'")
|
|
43
|
+
target_path = Path(raw_target).expanduser().resolve()
|
|
44
|
+
if bridge.has_native_support() and hasattr(bridge._native, "cat"):
|
|
45
|
+
code, content = bridge._native.cat(str(target_path))
|
|
46
|
+
else:
|
|
47
|
+
code, content = legacy.lgc_cat(target_path)
|
|
48
|
+
if code != 0:
|
|
49
|
+
return bridge.translate_error(code, raw_target)
|
|
50
|
+
lines = content.splitlines(keepends=True)
|
|
51
|
+
total_lines = len(lines)
|
|
52
|
+
if limit is not None:
|
|
53
|
+
lines = lines[:limit]
|
|
54
|
+
output_lines = [
|
|
55
|
+
f"\nDisplaying contents of file '{target_path.name}' ({len(lines)}/{total_lines} lines)\n"
|
|
56
|
+
]
|
|
57
|
+
for line_idx, line in enumerate(lines, start=1):
|
|
58
|
+
clean_line = line.rstrip("\r\n")
|
|
59
|
+
if show_numbers:
|
|
60
|
+
output_lines.append(f"{line_idx:4d} | {clean_line}")
|
|
61
|
+
else:
|
|
62
|
+
output_lines.append(clean_line)
|
|
63
|
+
output_lines.append(f"\nEnd of '{target_path.name}'\n")
|
|
64
|
+
return (0, "\n".join(output_lines))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class Dir(BaseCmd):
|
|
68
|
+
name = "dir"
|
|
69
|
+
description = "List all files in the current working directory"
|
|
70
|
+
min_args = 0
|
|
71
|
+
options = None
|
|
72
|
+
aliases = ["ls"]
|
|
73
|
+
|
|
74
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
75
|
+
target_str = args[0].strip("\"'") if args else os.getcwd()
|
|
76
|
+
target_path = Path(target_str).expanduser().resolve()
|
|
77
|
+
if bridge.has_native_support() and hasattr(bridge._native, "dir"):
|
|
78
|
+
code, items = bridge._native.dir(str(target_path))
|
|
79
|
+
else:
|
|
80
|
+
code, items = legacy.lgc_dir(target_path)
|
|
81
|
+
if code != 0:
|
|
82
|
+
return bridge.translate_error(code, str(target_path))
|
|
83
|
+
lines = [f"\nDirectory: '{target_path}'"]
|
|
84
|
+
for name, is_dir in items:
|
|
85
|
+
if is_dir:
|
|
86
|
+
lines.append(f"[DIR] {name}/")
|
|
87
|
+
else:
|
|
88
|
+
lines.append(f"[FILE] {name}")
|
|
89
|
+
lines.append(f"\nTotal items in directory: {len(items)}\n")
|
|
90
|
+
return (0, "\n".join(lines))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class MkDir(BaseCmd):
|
|
94
|
+
name = "mkdir"
|
|
95
|
+
description = "Create a new directory from the current working directory"
|
|
96
|
+
min_args = 1
|
|
97
|
+
options = "Directory name"
|
|
98
|
+
aliases = ["md"]
|
|
99
|
+
|
|
100
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
101
|
+
use_parents = ("-p" in args) or ("--parents" in args)
|
|
102
|
+
path_tokens = [arg for arg in args if arg not in ("-p", "--parents")]
|
|
103
|
+
if not path_tokens:
|
|
104
|
+
return (1, "\nCommand Error: Directory name not specified.\n")
|
|
105
|
+
raw_target = " ".join(path_tokens).strip("\"'")
|
|
106
|
+
target_path = Path(raw_target).expanduser()
|
|
107
|
+
if bridge.has_native_support() and hasattr(bridge._native, "mkdir"):
|
|
108
|
+
code, _ = bridge._native.mkdir(str(target_path), use_parents)
|
|
109
|
+
else:
|
|
110
|
+
code, _ = legacy.lgc_mkdir(target_path, use_parents)
|
|
111
|
+
if code != 0:
|
|
112
|
+
if code == -1 and not use_parents:
|
|
113
|
+
return (
|
|
114
|
+
1,
|
|
115
|
+
"\nSystem Error: Parent directory does not exist. Use '-p' or '--parents' to create parent directories.\n",
|
|
116
|
+
)
|
|
117
|
+
return bridge.translate_error(code, raw_target)
|
|
118
|
+
return (0, f"\nSUCCESS! Created directory '{raw_target}'\n")
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class Touch(BaseCmd):
|
|
122
|
+
name = "touch"
|
|
123
|
+
description = "Create an empty file or update existing file timestamps"
|
|
124
|
+
min_args = 1
|
|
125
|
+
options = "Target file"
|
|
126
|
+
|
|
127
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
128
|
+
if not args:
|
|
129
|
+
return (1, "\nCommand Error: Target file not specified.\n")
|
|
130
|
+
raw_target = " ".join(args).strip("\"'")
|
|
131
|
+
target_path = Path(raw_target).expanduser().resolve()
|
|
132
|
+
if bridge.has_native_support() and hasattr(bridge._native, "touch"):
|
|
133
|
+
code, _ = bridge._native.touch(str(target_path))
|
|
134
|
+
else:
|
|
135
|
+
code, _ = legacy.lgc_touch(target_path)
|
|
136
|
+
if code != 0:
|
|
137
|
+
return bridge.translate_error(code, raw_target)
|
|
138
|
+
return (0, f"\nSUCCESS! File '{raw_target}' touched successfully.\n")
|