flyshell 1.4.10__tar.gz → 1.5.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.4.10/src/flyshell.egg-info → flyshell-1.5.0}/PKG-INFO +6 -12
- {flyshell-1.4.10 → flyshell-1.5.0}/README.md +5 -11
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/diskops.c +16 -1
- flyshell-1.5.0/c_src/diskops/posix/mv.c +52 -0
- flyshell-1.5.0/c_src/diskops/win32/mv.c +74 -0
- flyshell-1.5.0/setup.py +53 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/constants.py +2 -3
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/core/directory.py +1 -2
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/native/diskops_handler.py +65 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/native/legacy/diskops.py +25 -0
- {flyshell-1.4.10 → flyshell-1.5.0/src/flyshell.egg-info}/PKG-INFO +6 -12
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell.egg-info/SOURCES.txt +2 -2
- {flyshell-1.4.10 → flyshell-1.5.0}/tests/test_diskops_ext.py +44 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/tests/test_diskops_lgc.py +13 -0
- flyshell-1.4.10/setup.py +0 -47
- flyshell-1.4.10/src/flyshell/builtin/diskops.py +0 -350
- flyshell-1.4.10/tests/test_diskops_old.py +0 -41
- {flyshell-1.4.10 → flyshell-1.5.0}/LICENSE +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/MANIFEST.in +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/posix/cat.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/posix/cp.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/posix/dir.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/posix/mkdir.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/posix/rename.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/posix/rm.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/posix/rmdir.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/posix/touch.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/shared/dir_types.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/shared/dir_types.h +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/shared/native_errors.h +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/shared/win32_utf.h +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/win32/cat.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/win32/cp.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/win32/dir.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/win32/mkdir.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/win32/rename.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/win32/rm.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/win32/rmdir.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/c_src/diskops/win32/touch.c +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/pyproject.toml +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/setup.cfg +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/__init__.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/abstract/__init__.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/abstract/base_cmd.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/abstract/base_plugin.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/abstract/parent_cmd.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/accounts/__init__.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/accounts/auth.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/bin/__init__.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/builtin/__init__.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/builtin/fs.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/builtin/pkg.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/builtin/system.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/builtin/utils.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/core/__init__.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/core/console.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/core/data.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/main.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/native/__init__.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/native/diskops_bridge.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/native/legacy/__init__.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/startup/__init__.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/startup/deps.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/startup/env.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell/startup/loader.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell.egg-info/dependency_links.txt +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell.egg-info/entry_points.txt +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell.egg-info/requires.txt +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/src/flyshell.egg-info/top_level.txt +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/tests/test_auth.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/tests/test_data.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/tests/test_deps.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/tests/test_directory.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/tests/test_env.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/tests/test_fs.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/tests/test_loader.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/tests/test_pkg.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.0}/tests/test_security.py +0 -0
- {flyshell-1.4.10 → flyshell-1.5.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.5.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.5.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
|
|
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
|
|
|
@@ -62,7 +62,6 @@ src/
|
|
|
62
62
|
│ └── __init__.py
|
|
63
63
|
├── builtin/
|
|
64
64
|
│ ├── __init__.py
|
|
65
|
-
│ ├── diskops.py
|
|
66
65
|
│ ├── fs.py
|
|
67
66
|
│ ├── pkg.py
|
|
68
67
|
│ ├── system.py
|
|
@@ -119,15 +118,10 @@ Clone the GitHub repository:
|
|
|
119
118
|
git clone https://github.com/kianodev/flyshell.git
|
|
120
119
|
```
|
|
121
120
|
|
|
122
|
-
Switch to the Flyshell directory and install in editable mode:
|
|
121
|
+
Switch to the Flyshell directory and install in editable mode compiling the C-binaries:
|
|
123
122
|
```bash
|
|
124
123
|
cd flyshell
|
|
125
|
-
pip install -e .
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
Flyshell now uses C-binaries, you must compile these:
|
|
129
|
-
```bash
|
|
130
|
-
python setup.py build_ext --inplace
|
|
124
|
+
python -m pip install -e .
|
|
131
125
|
```
|
|
132
126
|
|
|
133
127
|
After this, you can simply run Flyshell:
|
|
@@ -216,7 +210,7 @@ Additional functions are available for you to use:
|
|
|
216
210
|
2. `set_data(key, value)`: Updates a key in local memory and automatically persists it to SQLite via `save_storage()`.
|
|
217
211
|
3. `load_storage()`: Reloads fresh key-value pairs directly from SQLite into `self.storage`.
|
|
218
212
|
4. `save_storage()`: Writes all in-memory key-value pairs in `self.storage` back to SQLite.
|
|
219
|
-
5. `get_api_key(
|
|
213
|
+
5. `get_api_key(key, default=None)`: Fetches the specified API key from `flyshell_keys.env`.
|
|
220
214
|
|
|
221
215
|
Plugins save automatically on shut-down.
|
|
222
216
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|

|
|
7
7
|

|
|
8
8
|
|
|
9
|
-
> Documentation last updated: v1.
|
|
9
|
+
> Documentation last updated: v1.5.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
|
|
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
|
|
|
@@ -45,7 +45,6 @@ src/
|
|
|
45
45
|
│ └── __init__.py
|
|
46
46
|
├── builtin/
|
|
47
47
|
│ ├── __init__.py
|
|
48
|
-
│ ├── diskops.py
|
|
49
48
|
│ ├── fs.py
|
|
50
49
|
│ ├── pkg.py
|
|
51
50
|
│ ├── system.py
|
|
@@ -102,15 +101,10 @@ Clone the GitHub repository:
|
|
|
102
101
|
git clone https://github.com/kianodev/flyshell.git
|
|
103
102
|
```
|
|
104
103
|
|
|
105
|
-
Switch to the Flyshell directory and install in editable mode:
|
|
104
|
+
Switch to the Flyshell directory and install in editable mode compiling the C-binaries:
|
|
106
105
|
```bash
|
|
107
106
|
cd flyshell
|
|
108
|
-
pip install -e .
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Flyshell now uses C-binaries, you must compile these:
|
|
112
|
-
```bash
|
|
113
|
-
python setup.py build_ext --inplace
|
|
107
|
+
python -m pip install -e .
|
|
114
108
|
```
|
|
115
109
|
|
|
116
110
|
After this, you can simply run Flyshell:
|
|
@@ -199,7 +193,7 @@ Additional functions are available for you to use:
|
|
|
199
193
|
2. `set_data(key, value)`: Updates a key in local memory and automatically persists it to SQLite via `save_storage()`.
|
|
200
194
|
3. `load_storage()`: Reloads fresh key-value pairs directly from SQLite into `self.storage`.
|
|
201
195
|
4. `save_storage()`: Writes all in-memory key-value pairs in `self.storage` back to SQLite.
|
|
202
|
-
5. `get_api_key(
|
|
196
|
+
5. `get_api_key(key, default=None)`: Fetches the specified API key from `flyshell_keys.env`.
|
|
203
197
|
|
|
204
198
|
Plugins save automatically on shut-down.
|
|
205
199
|
|
|
@@ -21,6 +21,8 @@ Result remove_item(const char *path, bool recursive);
|
|
|
21
21
|
|
|
22
22
|
Result copy_item(const char *src, const char *dst, bool force);
|
|
23
23
|
|
|
24
|
+
Result move_item(const char *src, const char *dst, bool force);
|
|
25
|
+
|
|
24
26
|
static PyObject *method_ping(PyObject *self, PyObject *args) {
|
|
25
27
|
return PyLong_FromLong(42);
|
|
26
28
|
}
|
|
@@ -152,6 +154,18 @@ static PyObject *method_cp(PyObject *self, PyObject *args) {
|
|
|
152
154
|
return Py_BuildValue("(is)", (int)res, "");
|
|
153
155
|
}
|
|
154
156
|
|
|
157
|
+
static PyObject *method_mv(PyObject *self, PyObject *args) {
|
|
158
|
+
const char *src;
|
|
159
|
+
const char *dst;
|
|
160
|
+
int force = 0;
|
|
161
|
+
if (!PyArg_ParseTuple(args, "ss|p", &src, &dst, &force)) {
|
|
162
|
+
return NULL;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
Result res = move_item(src, dst, force != 0);
|
|
166
|
+
return Py_BuildValue("(is)", (int)res, "");
|
|
167
|
+
}
|
|
168
|
+
|
|
155
169
|
static PyMethodDef DiskopsMethods[] = {
|
|
156
170
|
{"ping", method_ping, METH_NOARGS, "Health check ping."},
|
|
157
171
|
{"cat", method_cat, METH_VARARGS, "Read file content natively."},
|
|
@@ -161,7 +175,8 @@ static PyMethodDef DiskopsMethods[] = {
|
|
|
161
175
|
{"rename", method_rename, METH_VARARGS, "Rename file or directory natively."},
|
|
162
176
|
{"rmdir", method_rmdir, METH_VARARGS, "Remove directory natively."},
|
|
163
177
|
{"rm", method_rm, METH_VARARGS, "Remove file or directory natively."},
|
|
164
|
-
{"cp", method_cp, METH_VARARGS, "Copy
|
|
178
|
+
{"cp", method_cp, METH_VARARGS, "Copy file or directory natively."},
|
|
179
|
+
{"mv", method_mv, METH_VARARGS, "Move file or directory natively."},
|
|
165
180
|
{NULL, NULL, 0, NULL},
|
|
166
181
|
};
|
|
167
182
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// c_src/diskops/posix/mv.c
|
|
2
|
+
|
|
3
|
+
#include "../shared/native_errors.h"
|
|
4
|
+
#include <errno.h>
|
|
5
|
+
#include <stdbool.h>
|
|
6
|
+
#include <stdio.h>
|
|
7
|
+
#include <sys/stat.h>
|
|
8
|
+
|
|
9
|
+
Result copy_item(const char *src, const char *dst, bool force);
|
|
10
|
+
Result remove_item(const char *path, bool recursive);
|
|
11
|
+
|
|
12
|
+
Result move_item(const char *src, const char *dst, bool force) {
|
|
13
|
+
if (!src || src[0] == '\0' || !dst || dst[0] == '\0') {
|
|
14
|
+
return ERR_INVALID_PATH;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
struct stat src_st;
|
|
18
|
+
if (lstat(src, &src_st) != 0) {
|
|
19
|
+
return map_posix_errno(errno);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
struct stat dst_st;
|
|
23
|
+
if (lstat(dst, &dst_st) == 0) {
|
|
24
|
+
if (src_st.st_dev == dst_st.st_dev && src_st.st_ino == dst_st.st_ino) {
|
|
25
|
+
return ERR_SAME_FILE;
|
|
26
|
+
}
|
|
27
|
+
if (!force) {
|
|
28
|
+
return ERR_EXISTS;
|
|
29
|
+
}
|
|
30
|
+
if (S_ISDIR(dst_st.st_mode)) {
|
|
31
|
+
Result rm_res = remove_item(dst, true);
|
|
32
|
+
if (rm_res != SUCCESS) {
|
|
33
|
+
return rm_res;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (rename(src, dst) == 0) {
|
|
39
|
+
return SUCCESS;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (errno != EXDEV) {
|
|
43
|
+
return map_posix_errno(errno);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
Result cp_res = copy_item(src, dst, true);
|
|
47
|
+
if (cp_res != SUCCESS) {
|
|
48
|
+
return cp_res;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return remove_item(src, true);
|
|
52
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// c_src/diskops/win32/mv.c
|
|
2
|
+
|
|
3
|
+
#include "../shared/native_errors.h"
|
|
4
|
+
#include "../shared/win32_utf.h"
|
|
5
|
+
#include <stdbool.h>
|
|
6
|
+
#include <stdlib.h>
|
|
7
|
+
#include <windows.h>
|
|
8
|
+
|
|
9
|
+
Result copy_item(const char *src, const char *dst, bool force);
|
|
10
|
+
Result remove_item(const char *path, bool recursive);
|
|
11
|
+
|
|
12
|
+
Result move_item(const char *src, const char *dst, bool force) {
|
|
13
|
+
if (!src || src[0] == '\0' || !dst || dst[0] == '\0') {
|
|
14
|
+
return ERR_INVALID_PATH;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
wchar_t *wsrc = utf8_to_wide(src);
|
|
18
|
+
if (!wsrc) {
|
|
19
|
+
return ERR_INVALID_PATH;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
wchar_t *wdst = utf8_to_wide(dst);
|
|
23
|
+
if (!wdst) {
|
|
24
|
+
free(wsrc);
|
|
25
|
+
return ERR_INVALID_PATH;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
DWORD src_attrs = GetFileAttributesW(wsrc);
|
|
29
|
+
if (src_attrs == INVALID_FILE_ATTRIBUTES) {
|
|
30
|
+
DWORD err = GetLastError();
|
|
31
|
+
free(wsrc);
|
|
32
|
+
free(wdst);
|
|
33
|
+
return map_win32_error(err);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
DWORD dst_attrs = GetFileAttributesW(wdst);
|
|
37
|
+
if (dst_attrs != INVALID_FILE_ATTRIBUTES) {
|
|
38
|
+
if (!force) {
|
|
39
|
+
free(wsrc);
|
|
40
|
+
free(wdst);
|
|
41
|
+
return ERR_EXISTS;
|
|
42
|
+
}
|
|
43
|
+
if ((dst_attrs & FILE_ATTRIBUTE_DIRECTORY) != 0) {
|
|
44
|
+
Result rm_res = remove_item(dst, true);
|
|
45
|
+
if (rm_res != SUCCESS) {
|
|
46
|
+
free(wsrc);
|
|
47
|
+
free(wdst);
|
|
48
|
+
return rm_res;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
DWORD flags = force ? MOVEFILE_REPLACE_EXISTING : 0;
|
|
54
|
+
if (MoveFileExW(wsrc, wdst, flags) != 0) {
|
|
55
|
+
free(wsrc);
|
|
56
|
+
free(wdst);
|
|
57
|
+
return SUCCESS;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
DWORD err = GetLastError();
|
|
61
|
+
free(wsrc);
|
|
62
|
+
free(wdst);
|
|
63
|
+
|
|
64
|
+
if (err != ERROR_NOT_SAME_DEVICE) {
|
|
65
|
+
return map_win32_error(err);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Result cp_res = copy_item(src, dst, true);
|
|
69
|
+
if (cp_res != SUCCESS) {
|
|
70
|
+
return cp_res;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return remove_item(src, true);
|
|
74
|
+
}
|
flyshell-1.5.0/setup.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# setup.py
|
|
2
|
+
|
|
3
|
+
from setuptools import Extension, setup
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
sources = [
|
|
7
|
+
"c_src/diskops/diskops.c",
|
|
8
|
+
"c_src/diskops/shared/dir_types.c",
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
define_macros = []
|
|
12
|
+
|
|
13
|
+
if sys.platform == "win32":
|
|
14
|
+
sources.extend(
|
|
15
|
+
[
|
|
16
|
+
"c_src/diskops/win32/cat.c",
|
|
17
|
+
"c_src/diskops/win32/cp.c",
|
|
18
|
+
"c_src/diskops/win32/dir.c",
|
|
19
|
+
"c_src/diskops/win32/mkdir.c",
|
|
20
|
+
"c_src/diskops/win32/mv.c",
|
|
21
|
+
"c_src/diskops/win32/rename.c",
|
|
22
|
+
"c_src/diskops/win32/rm.c",
|
|
23
|
+
"c_src/diskops/win32/rmdir.c",
|
|
24
|
+
"c_src/diskops/win32/touch.c",
|
|
25
|
+
]
|
|
26
|
+
)
|
|
27
|
+
else:
|
|
28
|
+
if sys.platform == "darwin":
|
|
29
|
+
define_macros.append(("_DARWIN_C_SOURCE", "1"))
|
|
30
|
+
sources.extend(
|
|
31
|
+
[
|
|
32
|
+
"c_src/diskops/posix/cat.c",
|
|
33
|
+
"c_src/diskops/posix/cp.c",
|
|
34
|
+
"c_src/diskops/posix/dir.c",
|
|
35
|
+
"c_src/diskops/posix/mkdir.c",
|
|
36
|
+
"c_src/diskops/posix/mv.c",
|
|
37
|
+
"c_src/diskops/posix/rename.c",
|
|
38
|
+
"c_src/diskops/posix/rm.c",
|
|
39
|
+
"c_src/diskops/posix/rmdir.c",
|
|
40
|
+
"c_src/diskops/posix/touch.c",
|
|
41
|
+
]
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
native_diskops = Extension(
|
|
45
|
+
name="flyshell.bin._native_diskops",
|
|
46
|
+
sources=sources,
|
|
47
|
+
include_dirs=["c_src/diskops/shared"],
|
|
48
|
+
define_macros=define_macros,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
setup(
|
|
52
|
+
ext_modules=[native_diskops],
|
|
53
|
+
)
|
|
@@ -5,8 +5,8 @@ import os
|
|
|
5
5
|
import platform
|
|
6
6
|
import time
|
|
7
7
|
|
|
8
|
-
BUILD =
|
|
9
|
-
VERSION = "1.
|
|
8
|
+
BUILD = 166
|
|
9
|
+
VERSION = "1.5.0"
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def _resolve_app_dir() -> Path:
|
|
@@ -58,7 +58,6 @@ REQUIRED_COMPONENTS = [
|
|
|
58
58
|
"bin/__init__.py",
|
|
59
59
|
"builtin",
|
|
60
60
|
"builtin/__init__.py",
|
|
61
|
-
"builtin/diskops.py",
|
|
62
61
|
"builtin/fs.py",
|
|
63
62
|
"builtin/pkg.py",
|
|
64
63
|
"builtin/system.py",
|
|
@@ -4,7 +4,6 @@ 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
6
|
from flyshell.accounts import auth
|
|
7
|
-
from flyshell.builtin import diskops as diskops_legacy
|
|
8
7
|
from flyshell.builtin import fs, pkg, system, utils
|
|
9
8
|
from flyshell.core import data
|
|
10
9
|
from flyshell.native import diskops_handler as diskops
|
|
@@ -66,7 +65,7 @@ INSTALLED_COMMANDS: list[BaseCmd] = [
|
|
|
66
65
|
utils.Kill(),
|
|
67
66
|
auth.Lock(),
|
|
68
67
|
diskops.MkDir(),
|
|
69
|
-
|
|
68
|
+
diskops.Move(),
|
|
70
69
|
system.OpenFile(),
|
|
71
70
|
pkg.Pkg(),
|
|
72
71
|
utils.Reboot(),
|
|
@@ -204,6 +204,71 @@ class Dir(BaseCmd):
|
|
|
204
204
|
return (0, "\n".join(lines))
|
|
205
205
|
|
|
206
206
|
|
|
207
|
+
class Move(BaseCmd):
|
|
208
|
+
name = "mv"
|
|
209
|
+
description = "Move or relocate files and directories"
|
|
210
|
+
min_args = 2
|
|
211
|
+
options = "Source, then destination"
|
|
212
|
+
aliases = ["move"]
|
|
213
|
+
|
|
214
|
+
def execute(self, args):
|
|
215
|
+
force = ("-f" in args) or ("--force" in args)
|
|
216
|
+
flags = {"-f", "--force"}
|
|
217
|
+
path_tokens = [arg for arg in args if arg not in flags]
|
|
218
|
+
if len(path_tokens) < 2:
|
|
219
|
+
return (
|
|
220
|
+
1,
|
|
221
|
+
"\nCommand Error: 'mv' requires both a source and a destination path.\n",
|
|
222
|
+
)
|
|
223
|
+
raw_src = path_tokens[0].strip("\"'")
|
|
224
|
+
raw_dst = path_tokens[1].strip("\"'")
|
|
225
|
+
src_path = Path(raw_src).expanduser().resolve()
|
|
226
|
+
dst_path = Path(raw_dst).expanduser().resolve()
|
|
227
|
+
if not src_path.exists():
|
|
228
|
+
return (1, f"\nSystem Error: Source '{raw_src}' not found.\n")
|
|
229
|
+
if src_path == src_path.parent or str(src_path) == src_path.anchor:
|
|
230
|
+
return (
|
|
231
|
+
1,
|
|
232
|
+
"\nSecurity Error: Flyshell has blocked moving the root filesystem.\n",
|
|
233
|
+
)
|
|
234
|
+
flyshell_dirs = [
|
|
235
|
+
c.APP_DIR.resolve(),
|
|
236
|
+
c.PACKAGE_ROOT.resolve(),
|
|
237
|
+
c.PROJECT_ROOT.resolve(),
|
|
238
|
+
]
|
|
239
|
+
for protected in flyshell_dirs:
|
|
240
|
+
if src_path == protected or src_path.is_relative_to(protected):
|
|
241
|
+
return (
|
|
242
|
+
1,
|
|
243
|
+
"\nSecurity Error: Flyshell has blocked this action.\n"
|
|
244
|
+
f"Source '{raw_src}' contains or belongs to Flyshell system files.\n",
|
|
245
|
+
)
|
|
246
|
+
if dst_path.exists() and dst_path.is_dir():
|
|
247
|
+
final_dst = dst_path / src_path.name
|
|
248
|
+
else:
|
|
249
|
+
final_dst = dst_path
|
|
250
|
+
if final_dst.exists() and not force:
|
|
251
|
+
try:
|
|
252
|
+
confirm = (
|
|
253
|
+
input(
|
|
254
|
+
f"\nDestination '{final_dst.name}' already exists. Overwrite? [y/n]: "
|
|
255
|
+
)
|
|
256
|
+
.strip()
|
|
257
|
+
.lower()
|
|
258
|
+
)
|
|
259
|
+
except (KeyboardInterrupt, EOFError):
|
|
260
|
+
return (1, "\nMove cancelled by user.\n")
|
|
261
|
+
if confirm != "y":
|
|
262
|
+
return (0, "\nOperation cancelled. No files were moved.\n")
|
|
263
|
+
if bridge.has_native_support() and hasattr(bridge._native, "mv"):
|
|
264
|
+
code, _ = bridge._native.mv(str(src_path), str(final_dst), force)
|
|
265
|
+
else:
|
|
266
|
+
code, _ = legacy.lgc_mv(src_path, final_dst, force)
|
|
267
|
+
if code != 0:
|
|
268
|
+
return bridge.translate_error(code, raw_src)
|
|
269
|
+
return (0, f"\nSUCCESS! Moved '{src_path.name}' -> '{final_dst}'\n")
|
|
270
|
+
|
|
271
|
+
|
|
207
272
|
class MkDir(BaseCmd):
|
|
208
273
|
name = "mkdir"
|
|
209
274
|
description = "Create a new directory from the current working directory"
|
|
@@ -99,6 +99,31 @@ def lgc_mkdir(target_path: Path, parents: bool = False) -> tuple[int, str]:
|
|
|
99
99
|
return (-99, "") # ERR_UNKNOWN
|
|
100
100
|
|
|
101
101
|
|
|
102
|
+
def lgc_mv(src_path: Path, dst_path: Path, force: bool = False) -> tuple[int, str]:
|
|
103
|
+
if not src_path.exists():
|
|
104
|
+
return (-1, "") # ERR_NOT_FOUND
|
|
105
|
+
if src_path == dst_path:
|
|
106
|
+
return (-7, "") # ERR_SAME_FILE
|
|
107
|
+
if dst_path.exists() and not force:
|
|
108
|
+
return (-5, "") # ERR_EXISTS
|
|
109
|
+
try:
|
|
110
|
+
if dst_path.exists() and force:
|
|
111
|
+
if dst_path.is_dir():
|
|
112
|
+
shutil.rmtree(dst_path)
|
|
113
|
+
else:
|
|
114
|
+
os.remove(dst_path)
|
|
115
|
+
shutil.move(str(src_path), str(dst_path))
|
|
116
|
+
return (0, "") # SUCCESS
|
|
117
|
+
except shutil.SameFileError:
|
|
118
|
+
return (-7, "") # ERR_SAME_FILE
|
|
119
|
+
except PermissionError:
|
|
120
|
+
return (-2, "") # ERR_PERMISSION
|
|
121
|
+
except OSError:
|
|
122
|
+
return (-13, "") # ERR_IO
|
|
123
|
+
except Exception:
|
|
124
|
+
return (-99, "") # ERR_UNKNOWN
|
|
125
|
+
|
|
126
|
+
|
|
102
127
|
def lgc_rename(src_path: Path, dst_path: Path) -> tuple[int, str]:
|
|
103
128
|
if not src_path.exists():
|
|
104
129
|
return (-1, "") # ERR_NOT_FOUND
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flyshell
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.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.5.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
|
|
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
|
|
|
@@ -62,7 +62,6 @@ src/
|
|
|
62
62
|
│ └── __init__.py
|
|
63
63
|
├── builtin/
|
|
64
64
|
│ ├── __init__.py
|
|
65
|
-
│ ├── diskops.py
|
|
66
65
|
│ ├── fs.py
|
|
67
66
|
│ ├── pkg.py
|
|
68
67
|
│ ├── system.py
|
|
@@ -119,15 +118,10 @@ Clone the GitHub repository:
|
|
|
119
118
|
git clone https://github.com/kianodev/flyshell.git
|
|
120
119
|
```
|
|
121
120
|
|
|
122
|
-
Switch to the Flyshell directory and install in editable mode:
|
|
121
|
+
Switch to the Flyshell directory and install in editable mode compiling the C-binaries:
|
|
123
122
|
```bash
|
|
124
123
|
cd flyshell
|
|
125
|
-
pip install -e .
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
Flyshell now uses C-binaries, you must compile these:
|
|
129
|
-
```bash
|
|
130
|
-
python setup.py build_ext --inplace
|
|
124
|
+
python -m pip install -e .
|
|
131
125
|
```
|
|
132
126
|
|
|
133
127
|
After this, you can simply run Flyshell:
|
|
@@ -216,7 +210,7 @@ Additional functions are available for you to use:
|
|
|
216
210
|
2. `set_data(key, value)`: Updates a key in local memory and automatically persists it to SQLite via `save_storage()`.
|
|
217
211
|
3. `load_storage()`: Reloads fresh key-value pairs directly from SQLite into `self.storage`.
|
|
218
212
|
4. `save_storage()`: Writes all in-memory key-value pairs in `self.storage` back to SQLite.
|
|
219
|
-
5. `get_api_key(
|
|
213
|
+
5. `get_api_key(key, default=None)`: Fetches the specified API key from `flyshell_keys.env`.
|
|
220
214
|
|
|
221
215
|
Plugins save automatically on shut-down.
|
|
222
216
|
|
|
@@ -8,6 +8,7 @@ c_src/diskops/posix/cat.c
|
|
|
8
8
|
c_src/diskops/posix/cp.c
|
|
9
9
|
c_src/diskops/posix/dir.c
|
|
10
10
|
c_src/diskops/posix/mkdir.c
|
|
11
|
+
c_src/diskops/posix/mv.c
|
|
11
12
|
c_src/diskops/posix/rename.c
|
|
12
13
|
c_src/diskops/posix/rm.c
|
|
13
14
|
c_src/diskops/posix/rmdir.c
|
|
@@ -20,6 +21,7 @@ c_src/diskops/win32/cat.c
|
|
|
20
21
|
c_src/diskops/win32/cp.c
|
|
21
22
|
c_src/diskops/win32/dir.c
|
|
22
23
|
c_src/diskops/win32/mkdir.c
|
|
24
|
+
c_src/diskops/win32/mv.c
|
|
23
25
|
c_src/diskops/win32/rename.c
|
|
24
26
|
c_src/diskops/win32/rm.c
|
|
25
27
|
c_src/diskops/win32/rmdir.c
|
|
@@ -41,7 +43,6 @@ src/flyshell/accounts/__init__.py
|
|
|
41
43
|
src/flyshell/accounts/auth.py
|
|
42
44
|
src/flyshell/bin/__init__.py
|
|
43
45
|
src/flyshell/builtin/__init__.py
|
|
44
|
-
src/flyshell/builtin/diskops.py
|
|
45
46
|
src/flyshell/builtin/fs.py
|
|
46
47
|
src/flyshell/builtin/pkg.py
|
|
47
48
|
src/flyshell/builtin/system.py
|
|
@@ -65,7 +66,6 @@ tests/test_deps.py
|
|
|
65
66
|
tests/test_directory.py
|
|
66
67
|
tests/test_diskops_ext.py
|
|
67
68
|
tests/test_diskops_lgc.py
|
|
68
|
-
tests/test_diskops_old.py
|
|
69
69
|
tests/test_env.py
|
|
70
70
|
tests/test_fs.py
|
|
71
71
|
tests/test_loader.py
|
|
@@ -11,6 +11,50 @@ def test_native_extension_loaded():
|
|
|
11
11
|
assert bridge._native.ping() == 42
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
def test_native_mv_file_and_directory(tmp_path):
|
|
15
|
+
cmd = handler.Move()
|
|
16
|
+
src_file = tmp_path / "move_src.txt"
|
|
17
|
+
src_file.write_text("relocate me", encoding="utf-8")
|
|
18
|
+
dst_file = tmp_path / "move_dst.txt"
|
|
19
|
+
exit_code, msg = cmd.execute([str(src_file), str(dst_file)])
|
|
20
|
+
assert exit_code == 0
|
|
21
|
+
assert "Moved" in msg
|
|
22
|
+
assert not src_file.exists()
|
|
23
|
+
assert dst_file.read_text(encoding="utf-8") == "relocate me"
|
|
24
|
+
replacement = tmp_path / "new_src.txt"
|
|
25
|
+
replacement.write_text("overwritten", encoding="utf-8")
|
|
26
|
+
exit_code, msg = cmd.execute(["-f", str(replacement), str(dst_file)])
|
|
27
|
+
assert exit_code == 0
|
|
28
|
+
assert not replacement.exists()
|
|
29
|
+
assert dst_file.read_text(encoding="utf-8") == "overwritten"
|
|
30
|
+
src_dir = tmp_path / "dir_to_move"
|
|
31
|
+
src_dir.mkdir()
|
|
32
|
+
(src_dir / "item.txt").write_text("inside", encoding="utf-8")
|
|
33
|
+
target_parent = tmp_path / "dest_holder"
|
|
34
|
+
target_parent.mkdir()
|
|
35
|
+
exit_code, msg = cmd.execute([str(src_dir), str(target_parent)])
|
|
36
|
+
assert exit_code == 0
|
|
37
|
+
assert not src_dir.exists()
|
|
38
|
+
assert (target_parent / "dir_to_move" / "item.txt").read_text(
|
|
39
|
+
encoding="utf-8"
|
|
40
|
+
) == "inside"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_native_mv_errors(tmp_path):
|
|
44
|
+
cmd = handler.Move()
|
|
45
|
+
exit_code, msg = cmd.execute(
|
|
46
|
+
[str(tmp_path / "missing.txt"), str(tmp_path / "out.txt")]
|
|
47
|
+
)
|
|
48
|
+
assert exit_code == 1
|
|
49
|
+
assert "not found" in msg
|
|
50
|
+
a = tmp_path / "a.txt"
|
|
51
|
+
b = tmp_path / "b.txt"
|
|
52
|
+
a.write_text("1", encoding="utf-8")
|
|
53
|
+
b.write_text("2", encoding="utf-8")
|
|
54
|
+
code, _ = bridge._native.mv(str(a), str(b), False)
|
|
55
|
+
assert code == -5 # ERR_EXISTS
|
|
56
|
+
|
|
57
|
+
|
|
14
58
|
def test_native_cp_file_and_directory(tmp_path):
|
|
15
59
|
cmd = handler.Copy()
|
|
16
60
|
src_file = tmp_path / "src.txt"
|
|
@@ -12,6 +12,19 @@ def force_legacy_backend(monkeypatch):
|
|
|
12
12
|
monkeypatch.setattr(bridge, "has_native_support", lambda: False)
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
def test_legacy_mv_file_and_errors(tmp_path):
|
|
16
|
+
cmd = handler.Move()
|
|
17
|
+
src_file = tmp_path / "lgc_move_src.txt"
|
|
18
|
+
src_file.write_text("data", encoding="utf-8")
|
|
19
|
+
dst_file = tmp_path / "lgc_move_dst.txt"
|
|
20
|
+
exit_code, msg = cmd.execute([str(src_file), str(dst_file)])
|
|
21
|
+
assert exit_code == 0
|
|
22
|
+
assert not src_file.exists()
|
|
23
|
+
assert dst_file.read_text(encoding="utf-8") == "data"
|
|
24
|
+
code, _ = legacy.lgc_mv(tmp_path / "ghost.txt", tmp_path / "out.txt", force=False)
|
|
25
|
+
assert code == -1 # ERR_NOT_FOUND
|
|
26
|
+
|
|
27
|
+
|
|
15
28
|
def test_legacy_cp_file_and_directory(tmp_path):
|
|
16
29
|
cmd = handler.Copy()
|
|
17
30
|
src_file = tmp_path / "lgc_src.txt"
|