flyshell 1.0.6__tar.gz → 1.0.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.0.6/src/flyshell.egg-info → flyshell-1.0.8}/PKG-INFO +1 -1
- flyshell-1.0.8/src/flyshell/builtin/diskops.py +114 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/builtin/system.py +0 -23
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/constants.py +3 -2
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/core/data.py +1 -1
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/core/directory.py +4 -2
- {flyshell-1.0.6 → flyshell-1.0.8/src/flyshell.egg-info}/PKG-INFO +1 -1
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell.egg-info/SOURCES.txt +1 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/LICENSE +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/README.md +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/pyproject.toml +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/setup.cfg +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/__init__.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/abstract/__init__.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/abstract/base_cmd.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/abstract/base_plugin.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/abstract/parent_cmd.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/builtin/__init__.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/builtin/fs.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/builtin/utils.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/core/__init__.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/core/auth.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/core/console.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/core/loader.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell/main.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell.egg-info/dependency_links.txt +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell.egg-info/entry_points.txt +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell.egg-info/requires.txt +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/src/flyshell.egg-info/top_level.txt +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/tests/test_auth.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/tests/test_data.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/tests/test_directory.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/tests/test_loader.py +0 -0
- {flyshell-1.0.6 → flyshell-1.0.8}/tests/test_security.py +0 -0
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
class MkDir(BaseCmd):
|
|
34
|
+
name = "mkdir"
|
|
35
|
+
description = "Create a new directory from the current working directory"
|
|
36
|
+
min_args = 1
|
|
37
|
+
options = "Directory name"
|
|
38
|
+
aliases = ["md"]
|
|
39
|
+
|
|
40
|
+
def execute(self, args):
|
|
41
|
+
use_parents = ("-p" in args) or ("--parents" in args)
|
|
42
|
+
path_tokens = [arg for arg in args if arg not in ("-p", "--parents")]
|
|
43
|
+
target = " ".join(path_tokens).strip("\"'")
|
|
44
|
+
try:
|
|
45
|
+
if use_parents:
|
|
46
|
+
os.makedirs(target, exist_ok=True)
|
|
47
|
+
else:
|
|
48
|
+
os.mkdir(target)
|
|
49
|
+
return (0, f"\nSUCCESS! Created directory '{target}'\n")
|
|
50
|
+
except FileExistsError:
|
|
51
|
+
return (1, f"\nSystem Error: Directory '{target}' already exists.\n")
|
|
52
|
+
except FileNotFoundError:
|
|
53
|
+
return (1, f"\nSystem Error: Parent directory does not exist. Use '-p' or '--parents' to create parent directories.\n")
|
|
54
|
+
except PermissionError:
|
|
55
|
+
return (1, f"\nSystem Error: Permission denied. Cannot create '{target}'\n")
|
|
56
|
+
except Exception as e:
|
|
57
|
+
return (1, f"\nSystem Error: Unable to create directory '{target}' ({e})\n")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class RmDir(BaseCmd):
|
|
61
|
+
name = "rmdir"
|
|
62
|
+
description = "Remove the specified directory"
|
|
63
|
+
min_args = 1
|
|
64
|
+
options = "Target directory"
|
|
65
|
+
aliases = []
|
|
66
|
+
|
|
67
|
+
def execute(self, args):
|
|
68
|
+
force = ("-f" in args) or ("--force" in args)
|
|
69
|
+
path_tokens = [arg for arg in args if arg not in ("-f", "--force")]
|
|
70
|
+
raw_target = " ".join(path_tokens).strip("\"'")
|
|
71
|
+
target_path = Path(raw_target).expanduser().resolve()
|
|
72
|
+
if not target_path.exists():
|
|
73
|
+
return (1, f"\nSystem Error: Directory '{raw_target}' not found.\n")
|
|
74
|
+
if not target_path.is_dir():
|
|
75
|
+
return (1, f"\nCommand Error: '{raw_target}' is a file, not a directory.\n")
|
|
76
|
+
if target_path == target_path.anchor or target_path.parent == target_path:
|
|
77
|
+
return (
|
|
78
|
+
1,
|
|
79
|
+
"\nSecurity Error: Flyshell has blocked this action.\n"
|
|
80
|
+
"You cannot delete the root filesystem directory.\n",
|
|
81
|
+
)
|
|
82
|
+
flyshell_app = c.APP_DIR.resolve()
|
|
83
|
+
flyshell_package = c.PACKAGE_ROOT.resolve()
|
|
84
|
+
if target_path in (flyshell_app, flyshell_package) or flyshell_app in target_path.parents or flyshell_package in target_path.parents:
|
|
85
|
+
return (
|
|
86
|
+
1,
|
|
87
|
+
"\nSecurity Error: Flyshell has blocked this action.\n"
|
|
88
|
+
f"You cannot delete '{raw_target}' because it contains core Flyshell files or data.\n",
|
|
89
|
+
)
|
|
90
|
+
if target_path == Path(os.getcwd()).resolve():
|
|
91
|
+
return (
|
|
92
|
+
1,
|
|
93
|
+
"\nSystem Error: Cannot remove current working directory.\n"
|
|
94
|
+
"Switch to a different directory using 'cd' first.\n",
|
|
95
|
+
)
|
|
96
|
+
try:
|
|
97
|
+
has_contents = any(target_path.iterdir())
|
|
98
|
+
if has_contents and not force:
|
|
99
|
+
return (
|
|
100
|
+
1,
|
|
101
|
+
f"\nDirectory Error: Directory '{raw_target}' is not empty.\n"
|
|
102
|
+
"Use '-f' or '--force' to remove a non-empty directory and its contents.\n",
|
|
103
|
+
)
|
|
104
|
+
if has_contents and force:
|
|
105
|
+
shutil.rmtree(target_path)
|
|
106
|
+
else:
|
|
107
|
+
os.rmdir(target_path)
|
|
108
|
+
return (0, f"\nSUCCESS! Removed directory '{raw_target}'\n")
|
|
109
|
+
except PermissionError:
|
|
110
|
+
return (1, f"\nSystem Error: Permission denied. Cannot delete '{raw_target}'\n")
|
|
111
|
+
except OSError as e:
|
|
112
|
+
return (1, f"\nSystem Error: Unable to remove directory '{raw_target}' ({e.strerror})\n")
|
|
113
|
+
except Exception as e:
|
|
114
|
+
return (1, f"\nSystem Error: Unexpected error removing '{raw_target}' ({e})\n")
|
|
@@ -34,29 +34,6 @@ class Cd(BaseCmd):
|
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
class Dir(BaseCmd):
|
|
38
|
-
name = "dir"
|
|
39
|
-
description = "List all files in the current working directory"
|
|
40
|
-
min_args = 0
|
|
41
|
-
options = None
|
|
42
|
-
aliases = ["ls"]
|
|
43
|
-
|
|
44
|
-
def execute(self, args):
|
|
45
|
-
try:
|
|
46
|
-
current_path = os.getcwd()
|
|
47
|
-
items = os.listdir(current_path)
|
|
48
|
-
lines = [f"\nDirectory: '{current_path}'"]
|
|
49
|
-
for item in items:
|
|
50
|
-
if os.path.isdir(os.path.join(current_path, item)):
|
|
51
|
-
lines.append(f"[DIR] {item}/")
|
|
52
|
-
else:
|
|
53
|
-
lines.append(f"[FILE] {item}")
|
|
54
|
-
lines.append(f"\nTotal items in directory: {len(items)}\n")
|
|
55
|
-
return (0, "\n".join(lines))
|
|
56
|
-
except Exception as e:
|
|
57
|
-
return (1, f"\nSystem Error: Unable to list directory ({e})\n")
|
|
58
|
-
|
|
59
|
-
|
|
60
37
|
class OpenFile(BaseCmd):
|
|
61
38
|
name = "open"
|
|
62
39
|
description = "Open the specified file path"
|
|
@@ -7,8 +7,8 @@ import os
|
|
|
7
7
|
import platform
|
|
8
8
|
import time
|
|
9
9
|
|
|
10
|
-
BUILD =
|
|
11
|
-
VERSION = "1.0.
|
|
10
|
+
BUILD = 107
|
|
11
|
+
VERSION = "1.0.8"
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def _resolve_app_dir() -> Path:
|
|
@@ -53,6 +53,7 @@ REQUIRED_COMPONENTS = [
|
|
|
53
53
|
"abstract/base_plugin.py",
|
|
54
54
|
"abstract/parent_cmd.py",
|
|
55
55
|
"builtin",
|
|
56
|
+
"builtin/diskops.py",
|
|
56
57
|
"builtin/fs.py",
|
|
57
58
|
"builtin/system.py",
|
|
58
59
|
"builtin/utils.py",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from flyshell import constants as c
|
|
4
4
|
from flyshell.abstract.base_cmd import BaseCmd
|
|
5
5
|
from flyshell.abstract.parent_cmd import ParentCmd
|
|
6
|
-
from flyshell.builtin import fs, system, utils
|
|
6
|
+
from flyshell.builtin import diskops, fs, system, utils
|
|
7
7
|
from flyshell.core import auth, data
|
|
8
8
|
|
|
9
9
|
from datetime import datetime, timezone
|
|
@@ -52,13 +52,15 @@ INSTALLED_COMMANDS: list[BaseCmd] = [
|
|
|
52
52
|
system.Cd(),
|
|
53
53
|
Cmds(),
|
|
54
54
|
utils.Clear(),
|
|
55
|
-
|
|
55
|
+
diskops.Dir(),
|
|
56
56
|
fs.Fs(),
|
|
57
57
|
utils.History(),
|
|
58
58
|
utils.Kill(),
|
|
59
59
|
auth.Lock(),
|
|
60
|
+
diskops.MkDir(),
|
|
60
61
|
system.OpenFile(),
|
|
61
62
|
utils.Reboot(),
|
|
63
|
+
diskops.RmDir(),
|
|
62
64
|
utils.Sleep(),
|
|
63
65
|
system.SysExe(),
|
|
64
66
|
]
|
|
@@ -15,6 +15,7 @@ src/flyshell/abstract/base_cmd.py
|
|
|
15
15
|
src/flyshell/abstract/base_plugin.py
|
|
16
16
|
src/flyshell/abstract/parent_cmd.py
|
|
17
17
|
src/flyshell/builtin/__init__.py
|
|
18
|
+
src/flyshell/builtin/diskops.py
|
|
18
19
|
src/flyshell/builtin/fs.py
|
|
19
20
|
src/flyshell/builtin/system.py
|
|
20
21
|
src/flyshell/builtin/utils.py
|
|
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
|