flyshell 1.1.6__tar.gz → 1.1.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.1.6/src/flyshell.egg-info → flyshell-1.1.8}/PKG-INFO +1 -1
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/abstract/base_cmd.py +2 -2
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/builtin/diskops.py +2 -2
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/constants.py +2 -2
- {flyshell-1.1.6 → flyshell-1.1.8/src/flyshell.egg-info}/PKG-INFO +1 -1
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell.egg-info/SOURCES.txt +1 -0
- flyshell-1.1.8/tests/test_diskops.py +121 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/LICENSE +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/README.md +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/pyproject.toml +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/setup.cfg +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/__init__.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/abstract/__init__.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/abstract/base_plugin.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/abstract/parent_cmd.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/builtin/__init__.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/builtin/fs.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/builtin/system.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/builtin/utils.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/core/__init__.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/core/auth.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/core/console.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/core/data.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/core/directory.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/core/loader.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell/main.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell.egg-info/dependency_links.txt +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell.egg-info/entry_points.txt +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell.egg-info/requires.txt +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/src/flyshell.egg-info/top_level.txt +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/tests/test_auth.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/tests/test_data.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/tests/test_directory.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/tests/test_loader.py +0 -0
- {flyshell-1.1.6 → flyshell-1.1.8}/tests/test_security.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# src\flyshell\abstract\base_cmd.py
|
|
2
2
|
|
|
3
|
-
from typing import List, Optional, Tuple
|
|
3
|
+
from typing import List, Optional, Tuple
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class BaseCmd:
|
|
@@ -10,7 +10,7 @@ class BaseCmd:
|
|
|
10
10
|
options: Optional[str] = None
|
|
11
11
|
aliases: List[str] = []
|
|
12
12
|
|
|
13
|
-
def execute(self, args: List[str]) ->
|
|
13
|
+
def execute(self, args: List[str]) -> Tuple[int, str]:
|
|
14
14
|
raise NotImplementedError(
|
|
15
15
|
f"Command '{self.__class__.__name__}' has not implemented the execute method"
|
|
16
16
|
)
|
|
@@ -108,7 +108,7 @@ class Copy(BaseCmd):
|
|
|
108
108
|
.strip()
|
|
109
109
|
.lower()
|
|
110
110
|
)
|
|
111
|
-
except KeyboardInterrupt:
|
|
111
|
+
except (KeyboardInterrupt, EOFError):
|
|
112
112
|
return (1, "\nCopy cancelled by user.\n")
|
|
113
113
|
if confirm != "y":
|
|
114
114
|
return (0, "\nOperation cancelled. No files were copied.\n")
|
|
@@ -241,7 +241,7 @@ class Move(BaseCmd):
|
|
|
241
241
|
.strip()
|
|
242
242
|
.lower()
|
|
243
243
|
)
|
|
244
|
-
except KeyboardInterrupt:
|
|
244
|
+
except (KeyboardInterrupt, EOFError):
|
|
245
245
|
return (1, "\nMove cancelled by user.\n")
|
|
246
246
|
if confirm != "y":
|
|
247
247
|
return (0, "\nOperation cancelled. No files were moved.\n")
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# tests\test_diskops.py
|
|
2
|
+
|
|
3
|
+
from flyshell.builtin import diskops
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_touch_creates_file_and_updates_timestamp(tmp_path):
|
|
7
|
+
cmd = diskops.Touch()
|
|
8
|
+
target = tmp_path / "test.txt"
|
|
9
|
+
code, msg = cmd.execute([str(target)])
|
|
10
|
+
assert code == 0
|
|
11
|
+
assert "Created file" in msg
|
|
12
|
+
assert target.exists()
|
|
13
|
+
code, msg = cmd.execute([str(target)])
|
|
14
|
+
assert code == 0
|
|
15
|
+
assert "Updated timestamp" in msg
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_touch_missing_parent_directory(tmp_path):
|
|
19
|
+
cmd = diskops.Touch()
|
|
20
|
+
target = tmp_path / "nonexistent_dir" / "test.txt"
|
|
21
|
+
code, msg = cmd.execute([str(target)])
|
|
22
|
+
assert code == 1
|
|
23
|
+
assert "Parent directory does not exist" in msg
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_cat_reads_content_with_limit_and_numbers(tmp_path):
|
|
27
|
+
file_path = tmp_path / "sample.txt"
|
|
28
|
+
file_path.write_text("line 1\nline 2\nline 3\nline 4\n")
|
|
29
|
+
cmd = diskops.Cat()
|
|
30
|
+
code, msg = cmd.execute([str(file_path)])
|
|
31
|
+
assert code == 0
|
|
32
|
+
assert "line 1" in msg and "line 4" in msg
|
|
33
|
+
code, msg = cmd.execute(["-n", "-l", "2", str(file_path)])
|
|
34
|
+
assert code == 0
|
|
35
|
+
assert "1 | line 1" in msg
|
|
36
|
+
assert "2 | line 2" in msg
|
|
37
|
+
assert "line 3" not in msg
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_cat_nonexistent_and_empty_file(tmp_path):
|
|
41
|
+
cmd = diskops.Cat()
|
|
42
|
+
code, msg = cmd.execute([str(tmp_path / "missing.txt")])
|
|
43
|
+
assert code == 1
|
|
44
|
+
assert "not found" in msg
|
|
45
|
+
empty_file = tmp_path / "empty.txt"
|
|
46
|
+
empty_file.write_text("")
|
|
47
|
+
code, msg = cmd.execute([str(empty_file)])
|
|
48
|
+
assert code == 1
|
|
49
|
+
assert "is empty" in msg
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_mkdir_standard_and_parents(tmp_path):
|
|
53
|
+
cmd = diskops.MkDir()
|
|
54
|
+
target = tmp_path / "new_folder"
|
|
55
|
+
code, msg = cmd.execute([str(target)])
|
|
56
|
+
assert code == 0
|
|
57
|
+
assert target.is_dir()
|
|
58
|
+
code, msg = cmd.execute([str(target)])
|
|
59
|
+
assert code == 1
|
|
60
|
+
assert "already exists" in msg
|
|
61
|
+
nested = tmp_path / "parent" / "child"
|
|
62
|
+
code, msg = cmd.execute(["-p", str(nested)])
|
|
63
|
+
assert code == 0
|
|
64
|
+
assert nested.is_dir()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_rename_file(tmp_path):
|
|
68
|
+
src = tmp_path / "old.txt"
|
|
69
|
+
src.write_text("data")
|
|
70
|
+
cmd = diskops.Rename()
|
|
71
|
+
code, msg = cmd.execute([str(src), "new.txt"])
|
|
72
|
+
assert code == 0
|
|
73
|
+
assert not src.exists()
|
|
74
|
+
assert (tmp_path / "new.txt").exists()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_copy_file_and_directory(tmp_path):
|
|
78
|
+
src_file = tmp_path / "source.txt"
|
|
79
|
+
src_file.write_text("payload")
|
|
80
|
+
dst_file = tmp_path / "dest.txt"
|
|
81
|
+
cmd = diskops.Copy()
|
|
82
|
+
code, msg = cmd.execute([str(src_file), str(dst_file)])
|
|
83
|
+
assert code == 0
|
|
84
|
+
assert dst_file.read_text() == "payload"
|
|
85
|
+
src_dir = tmp_path / "src_dir"
|
|
86
|
+
src_dir.mkdir()
|
|
87
|
+
(src_dir / "item.txt").write_text("inner")
|
|
88
|
+
dst_dir = tmp_path / "dst_dir"
|
|
89
|
+
code, msg = cmd.execute([str(src_dir), str(dst_dir)])
|
|
90
|
+
assert code == 0
|
|
91
|
+
assert (dst_dir / "item.txt").exists()
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_rm_file_and_directory_recursive(tmp_path):
|
|
95
|
+
target_file = tmp_path / "del.txt"
|
|
96
|
+
target_file.write_text("bye")
|
|
97
|
+
cmd = diskops.Rm()
|
|
98
|
+
code, msg = cmd.execute(["-f", str(target_file)])
|
|
99
|
+
assert code == 0
|
|
100
|
+
assert not target_file.exists()
|
|
101
|
+
target_dir = tmp_path / "sub_dir"
|
|
102
|
+
target_dir.mkdir()
|
|
103
|
+
code, msg = cmd.execute(["-f", str(target_dir)])
|
|
104
|
+
assert code == 1
|
|
105
|
+
assert "is a directory" in msg
|
|
106
|
+
code, msg = cmd.execute(["-f", "-r", str(target_dir)])
|
|
107
|
+
assert code == 0
|
|
108
|
+
assert not target_dir.exists()
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def test_rmdir_empty_and_non_empty(tmp_path):
|
|
112
|
+
target_dir = tmp_path / "removable"
|
|
113
|
+
target_dir.mkdir()
|
|
114
|
+
cmd = diskops.RmDir()
|
|
115
|
+
(target_dir / "file.txt").write_text("data")
|
|
116
|
+
code, msg = cmd.execute([str(target_dir)])
|
|
117
|
+
assert code == 1
|
|
118
|
+
assert "not empty" in msg
|
|
119
|
+
code, msg = cmd.execute(["-f", str(target_dir)])
|
|
120
|
+
assert code == 0
|
|
121
|
+
assert not target_dir.exists()
|
|
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
|