flyshell 1.0.7__tar.gz → 1.0.9__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.0.7/src/flyshell.egg-info → flyshell-1.0.9}/PKG-INFO +1 -1
- flyshell-1.0.9/src/flyshell/builtin/diskops.py +152 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/constants.py +2 -2
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/core/directory.py +2 -0
- {flyshell-1.0.7 → flyshell-1.0.9/src/flyshell.egg-info}/PKG-INFO +1 -1
- flyshell-1.0.7/src/flyshell/builtin/diskops.py +0 -28
- {flyshell-1.0.7 → flyshell-1.0.9}/LICENSE +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/README.md +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/pyproject.toml +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/setup.cfg +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/__init__.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/abstract/__init__.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/abstract/base_cmd.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/abstract/base_plugin.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/abstract/parent_cmd.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/builtin/__init__.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/builtin/fs.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/builtin/system.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/builtin/utils.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/core/__init__.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/core/auth.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/core/console.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/core/data.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/core/loader.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell/main.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell.egg-info/SOURCES.txt +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell.egg-info/dependency_links.txt +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell.egg-info/entry_points.txt +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell.egg-info/requires.txt +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/src/flyshell.egg-info/top_level.txt +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/tests/test_auth.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/tests/test_data.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/tests/test_directory.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/tests/test_loader.py +0 -0
- {flyshell-1.0.7 → flyshell-1.0.9}/tests/test_security.py +0 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# src\flyshell\builtin\diskops.py
|
|
2
|
+
|
|
3
|
+
from flyshell import constants as c
|
|
4
|
+
from flyshell.abstract.base_cmd import BaseCmd
|
|
5
|
+
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import os
|
|
8
|
+
import shutil
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Dir(BaseCmd):
|
|
12
|
+
name = "dir"
|
|
13
|
+
description = "List all files in the current working directory"
|
|
14
|
+
min_args = 0
|
|
15
|
+
options = None
|
|
16
|
+
aliases = ["ls"]
|
|
17
|
+
|
|
18
|
+
def execute(self, args):
|
|
19
|
+
try:
|
|
20
|
+
current_path = os.getcwd()
|
|
21
|
+
items = os.listdir(current_path)
|
|
22
|
+
lines = [f"\nDirectory: '{current_path}'"]
|
|
23
|
+
for item in items:
|
|
24
|
+
if os.path.isdir(os.path.join(current_path, item)):
|
|
25
|
+
lines.append(f"[DIR] {item}/")
|
|
26
|
+
else:
|
|
27
|
+
lines.append(f"[FILE] {item}")
|
|
28
|
+
lines.append(f"\nTotal items in directory: {len(items)}\n")
|
|
29
|
+
return (0, "\n".join(lines))
|
|
30
|
+
except Exception as e:
|
|
31
|
+
return (1, f"\nSystem Error: Unable to list directory ({e})\n")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class MkDir(BaseCmd):
|
|
35
|
+
name = "mkdir"
|
|
36
|
+
description = "Create a new directory from the current working directory"
|
|
37
|
+
min_args = 1
|
|
38
|
+
options = "Directory name"
|
|
39
|
+
aliases = ["md"]
|
|
40
|
+
|
|
41
|
+
def execute(self, args):
|
|
42
|
+
use_parents = ("-p" in args) or ("--parents" in args)
|
|
43
|
+
path_tokens = [arg for arg in args if arg not in ("-p", "--parents")]
|
|
44
|
+
target = " ".join(path_tokens).strip("\"'")
|
|
45
|
+
try:
|
|
46
|
+
if use_parents:
|
|
47
|
+
os.makedirs(target, exist_ok=True)
|
|
48
|
+
else:
|
|
49
|
+
os.mkdir(target)
|
|
50
|
+
return (0, f"\nSUCCESS! Created directory '{target}'\n")
|
|
51
|
+
except FileExistsError:
|
|
52
|
+
return (1, f"\nSystem Error: Directory '{target}' already exists.\n")
|
|
53
|
+
except FileNotFoundError:
|
|
54
|
+
return (
|
|
55
|
+
1,
|
|
56
|
+
"\nSystem Error: Parent directory does not exist. Use '-p' or '--parents' to create parent directories.\n",
|
|
57
|
+
)
|
|
58
|
+
except PermissionError:
|
|
59
|
+
return (1, f"\nSystem Error: Permission denied. Cannot create '{target}'\n")
|
|
60
|
+
except Exception as e:
|
|
61
|
+
return (1, f"\nSystem Error: Unable to create directory '{target}' ({e})\n")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class RmDir(BaseCmd):
|
|
65
|
+
name = "rmdir"
|
|
66
|
+
description = "Remove the specified directory"
|
|
67
|
+
min_args = 1
|
|
68
|
+
options = "Target directory"
|
|
69
|
+
aliases = []
|
|
70
|
+
|
|
71
|
+
def execute(self, args):
|
|
72
|
+
force = ("-f" in args) or ("--force" in args)
|
|
73
|
+
path_tokens = [arg for arg in args if arg not in ("-f", "--force")]
|
|
74
|
+
raw_target = " ".join(path_tokens).strip("\"'")
|
|
75
|
+
target_path = Path(raw_target).expanduser().resolve()
|
|
76
|
+
if target_path == target_path.parent or str(target_path) == target_path.anchor:
|
|
77
|
+
return (
|
|
78
|
+
1,
|
|
79
|
+
"\nSecurity Error: Flyshell has blocked this action.\n"
|
|
80
|
+
"You cannot delete the root filesystem directory.\n",
|
|
81
|
+
)
|
|
82
|
+
critical_system_dirs = [
|
|
83
|
+
Path.home().parent.resolve(),
|
|
84
|
+
Path.home().resolve(),
|
|
85
|
+
]
|
|
86
|
+
if c.HOST_OS == "Windows":
|
|
87
|
+
system_drive = os.environ.get("SystemDrive", "C:")
|
|
88
|
+
critical_system_dirs.extend([
|
|
89
|
+
Path(f"{system_drive}\\Windows").resolve(),
|
|
90
|
+
Path(f"{system_drive}\\Program Files").resolve(),
|
|
91
|
+
Path(f"{system_drive}\\Program Files (x86)").resolve(),
|
|
92
|
+
])
|
|
93
|
+
else:
|
|
94
|
+
critical_system_dirs.extend([
|
|
95
|
+
Path("/bin").resolve(),
|
|
96
|
+
Path("/etc").resolve(),
|
|
97
|
+
Path("/usr").resolve(),
|
|
98
|
+
Path("/var").resolve(),
|
|
99
|
+
])
|
|
100
|
+
if target_path in critical_system_dirs:
|
|
101
|
+
return (
|
|
102
|
+
1,
|
|
103
|
+
"\nSecurity Error: Flyshell has blocked this action.\n"
|
|
104
|
+
f"Target '{raw_target}' is a protected operating system directory.\n",
|
|
105
|
+
)
|
|
106
|
+
if target_path == Path(os.getcwd()).resolve():
|
|
107
|
+
return (
|
|
108
|
+
1,
|
|
109
|
+
"\nSystem Error: Cannot remove current working directory.\n"
|
|
110
|
+
"Switch to a different directory using 'cd' first.\n",
|
|
111
|
+
)
|
|
112
|
+
flyshell_dirs = [
|
|
113
|
+
c.APP_DIR.resolve(),
|
|
114
|
+
c.PACKAGE_ROOT.resolve(),
|
|
115
|
+
c.PROJECT_ROOT.resolve(),
|
|
116
|
+
]
|
|
117
|
+
for protected in flyshell_dirs:
|
|
118
|
+
if target_path == protected or target_path.is_relative_to(protected):
|
|
119
|
+
return (
|
|
120
|
+
1,
|
|
121
|
+
"\nSecurity Error: Flyshell has blocked this action.\n"
|
|
122
|
+
f"Target '{raw_target}' contains or belongs to Flyshell system files.\n"
|
|
123
|
+
"If you wish to delete Flyshell, use the host.\n",
|
|
124
|
+
)
|
|
125
|
+
try:
|
|
126
|
+
has_contents = any(target_path.iterdir())
|
|
127
|
+
if has_contents and not force:
|
|
128
|
+
return (
|
|
129
|
+
1,
|
|
130
|
+
f"\nDirectory Error: Directory '{raw_target}' is not empty.\n"
|
|
131
|
+
"Use '-f' or '--force' to remove a non-empty directory and its contents.\n",
|
|
132
|
+
)
|
|
133
|
+
if has_contents and force:
|
|
134
|
+
shutil.rmtree(target_path)
|
|
135
|
+
else:
|
|
136
|
+
os.rmdir(target_path)
|
|
137
|
+
return (0, f"\nSUCCESS! Removed directory '{raw_target}'\n")
|
|
138
|
+
except PermissionError:
|
|
139
|
+
return (
|
|
140
|
+
1,
|
|
141
|
+
f"\nSystem Error: Permission denied. Cannot delete '{raw_target}'\n",
|
|
142
|
+
)
|
|
143
|
+
except OSError as e:
|
|
144
|
+
return (
|
|
145
|
+
1,
|
|
146
|
+
f"\nSystem Error: Unable to remove directory '{raw_target}' ({e.strerror})\n",
|
|
147
|
+
)
|
|
148
|
+
except Exception as e:
|
|
149
|
+
return (
|
|
150
|
+
1,
|
|
151
|
+
f"\nSystem Error: Unexpected error removing '{raw_target}' ({e})\n",
|
|
152
|
+
)
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# src\flyshell\builtin\diskops.py
|
|
2
|
-
|
|
3
|
-
from flyshell.abstract.base_cmd import BaseCmd
|
|
4
|
-
|
|
5
|
-
import os
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class Dir(BaseCmd):
|
|
9
|
-
name = "dir"
|
|
10
|
-
description = "List all files in the current working directory"
|
|
11
|
-
min_args = 0
|
|
12
|
-
options = None
|
|
13
|
-
aliases = ["ls"]
|
|
14
|
-
|
|
15
|
-
def execute(self, args):
|
|
16
|
-
try:
|
|
17
|
-
current_path = os.getcwd()
|
|
18
|
-
items = os.listdir(current_path)
|
|
19
|
-
lines = [f"\nDirectory: '{current_path}'"]
|
|
20
|
-
for item in items:
|
|
21
|
-
if os.path.isdir(os.path.join(current_path, item)):
|
|
22
|
-
lines.append(f"[DIR] {item}/")
|
|
23
|
-
else:
|
|
24
|
-
lines.append(f"[FILE] {item}")
|
|
25
|
-
lines.append(f"\nTotal items in directory: {len(items)}\n")
|
|
26
|
-
return (0, "\n".join(lines))
|
|
27
|
-
except Exception as e:
|
|
28
|
-
return (1, f"\nSystem Error: Unable to list directory ({e})\n")
|
|
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
|