flyshell 1.4.4__tar.gz → 1.4.6__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.4/src/flyshell.egg-info → flyshell-1.4.6}/PKG-INFO +7 -7
- {flyshell-1.4.4 → flyshell-1.4.6}/README.md +6 -6
- {flyshell-1.4.4 → flyshell-1.4.6}/c_src/diskops/diskops.c +14 -0
- flyshell-1.4.6/c_src/diskops/posix/mkdir.c +58 -0
- flyshell-1.4.6/c_src/diskops/win32/mkdir.c +72 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/setup.py +2 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/builtin/diskops.py +0 -30
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/constants.py +2 -2
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/core/directory.py +1 -1
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/native/diskops_handler.py +28 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/native/legacy/diskops.py +26 -0
- {flyshell-1.4.4 → flyshell-1.4.6/src/flyshell.egg-info}/PKG-INFO +7 -7
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell.egg-info/SOURCES.txt +2 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/tests/test_diskops_ext.py +56 -22
- {flyshell-1.4.4 → flyshell-1.4.6}/tests/test_diskops_lgc.py +59 -29
- {flyshell-1.4.4 → flyshell-1.4.6}/tests/test_diskops_old.py +0 -15
- {flyshell-1.4.4 → flyshell-1.4.6}/LICENSE +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/MANIFEST.in +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/c_src/diskops/posix/cat.c +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/c_src/diskops/posix/dir.c +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/c_src/diskops/posix/touch.c +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/c_src/diskops/shared/dir_types.c +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/c_src/diskops/shared/dir_types.h +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/c_src/diskops/shared/native_errors.h +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/c_src/diskops/shared/win32_utf.h +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/c_src/diskops/win32/cat.c +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/c_src/diskops/win32/dir.c +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/c_src/diskops/win32/touch.c +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/pyproject.toml +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/setup.cfg +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/__init__.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/abstract/__init__.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/abstract/base_cmd.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/abstract/base_plugin.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/abstract/parent_cmd.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/accounts/__init__.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/accounts/auth.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/bin/__init__.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/builtin/__init__.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/builtin/fs.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/builtin/pkg.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/builtin/system.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/builtin/utils.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/core/__init__.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/core/console.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/core/data.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/main.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/native/__init__.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/native/diskops_bridge.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/native/legacy/__init__.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/startup/__init__.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/startup/deps.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/startup/env.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell/startup/loader.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell.egg-info/dependency_links.txt +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell.egg-info/entry_points.txt +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell.egg-info/requires.txt +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/src/flyshell.egg-info/top_level.txt +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/tests/test_auth.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/tests/test_data.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/tests/test_deps.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/tests/test_directory.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/tests/test_env.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/tests/test_fs.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/tests/test_loader.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/tests/test_pkg.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/tests/test_security.py +0 -0
- {flyshell-1.4.4 → flyshell-1.4.6}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flyshell
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.6
|
|
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.4.
|
|
26
|
+
> Documentation last updated: v1.4.5
|
|
27
27
|
|
|
28
28
|
A modular, zero-dependency command-line environment and extensible runtime interface built in Python with compiled C-extensions.
|
|
29
29
|
|
|
@@ -177,7 +177,7 @@ All plugins must have an entry-point file. For single-file plugins, this is the
|
|
|
177
177
|
This file is what enables Flyshell to speak to your plugin.
|
|
178
178
|
|
|
179
179
|
```python
|
|
180
|
-
# Entry-point (my_plugin.py or my_plugin
|
|
180
|
+
# Entry-point (my_plugin.py or my_plugin/plugin.py)
|
|
181
181
|
|
|
182
182
|
from flyshell import BasePlugin # This is required
|
|
183
183
|
|
|
@@ -186,11 +186,11 @@ class MyPlugin(BasePlugin):
|
|
|
186
186
|
description = "This is my plugin." # A short one-line explaining what your plugin does
|
|
187
187
|
version = "1.0.0" # Default is 1.0.0
|
|
188
188
|
author = "kianodev" # You can put your name, your GitHub handle, or leave blank to make it 'Unknown'
|
|
189
|
-
|
|
189
|
+
identifier = "" # (OPTIONAL) Alternative name for your plugin command (defaults to dir / file name)
|
|
190
190
|
usage = "" # (OPTIONAL) Explain how to use your plugin
|
|
191
191
|
extended_help = "" # (OPTIONAL) A more detailed, multi-line guide containing specific assistance
|
|
192
|
-
api_keys = [] # (OPTIONAL) Define any required key names here. Use get_api_key(key_name) to call the key. Please add all keys in CAPITALS
|
|
193
|
-
third_pty_libs = [] # (OPTIONAL) Define all required third party libraries / dependencies here. Use their Python import names as this is how Flyshell checks them
|
|
192
|
+
api_keys = [] # (OPTIONAL) Define any required key names here. Use get_api_key(key_name) to call the key. Please add all keys in CAPITALS
|
|
193
|
+
third_pty_libs = [] # (OPTIONAL) Define all required third party libraries / dependencies here. Use their Python import names as this is how Flyshell checks them
|
|
194
194
|
|
|
195
195
|
def on_load(self): # (OPTIONAL) Enables your program to handle specialist set-up tasks before execute()
|
|
196
196
|
pass
|
|
@@ -211,7 +211,7 @@ Additional functions are available for you to use:
|
|
|
211
211
|
2. `set_data(key, value)`: Updates a key in local memory and automatically persists it to SQLite via `save_storage()`.
|
|
212
212
|
3. `load_storage()`: Reloads fresh key-value pairs directly from SQLite into `self.storage`.
|
|
213
213
|
4. `save_storage()`: Writes all in-memory key-value pairs in `self.storage` back to SQLite.
|
|
214
|
-
5. `get_api_key(
|
|
214
|
+
5. `get_api_key(self, default=None)`: Fetches the specified API key from `flyshell_keys.env`.
|
|
215
215
|
|
|
216
216
|
Plugins save automatically on shut-down.
|
|
217
217
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|

|
|
7
7
|

|
|
8
8
|
|
|
9
|
-
> Documentation last updated: v1.4.
|
|
9
|
+
> Documentation last updated: v1.4.5
|
|
10
10
|
|
|
11
11
|
A modular, zero-dependency command-line environment and extensible runtime interface built in Python with compiled C-extensions.
|
|
12
12
|
|
|
@@ -160,7 +160,7 @@ All plugins must have an entry-point file. For single-file plugins, this is the
|
|
|
160
160
|
This file is what enables Flyshell to speak to your plugin.
|
|
161
161
|
|
|
162
162
|
```python
|
|
163
|
-
# Entry-point (my_plugin.py or my_plugin
|
|
163
|
+
# Entry-point (my_plugin.py or my_plugin/plugin.py)
|
|
164
164
|
|
|
165
165
|
from flyshell import BasePlugin # This is required
|
|
166
166
|
|
|
@@ -169,11 +169,11 @@ class MyPlugin(BasePlugin):
|
|
|
169
169
|
description = "This is my plugin." # A short one-line explaining what your plugin does
|
|
170
170
|
version = "1.0.0" # Default is 1.0.0
|
|
171
171
|
author = "kianodev" # You can put your name, your GitHub handle, or leave blank to make it 'Unknown'
|
|
172
|
-
|
|
172
|
+
identifier = "" # (OPTIONAL) Alternative name for your plugin command (defaults to dir / file name)
|
|
173
173
|
usage = "" # (OPTIONAL) Explain how to use your plugin
|
|
174
174
|
extended_help = "" # (OPTIONAL) A more detailed, multi-line guide containing specific assistance
|
|
175
|
-
api_keys = [] # (OPTIONAL) Define any required key names here. Use get_api_key(key_name) to call the key. Please add all keys in CAPITALS
|
|
176
|
-
third_pty_libs = [] # (OPTIONAL) Define all required third party libraries / dependencies here. Use their Python import names as this is how Flyshell checks them
|
|
175
|
+
api_keys = [] # (OPTIONAL) Define any required key names here. Use get_api_key(key_name) to call the key. Please add all keys in CAPITALS
|
|
176
|
+
third_pty_libs = [] # (OPTIONAL) Define all required third party libraries / dependencies here. Use their Python import names as this is how Flyshell checks them
|
|
177
177
|
|
|
178
178
|
def on_load(self): # (OPTIONAL) Enables your program to handle specialist set-up tasks before execute()
|
|
179
179
|
pass
|
|
@@ -194,7 +194,7 @@ Additional functions are available for you to use:
|
|
|
194
194
|
2. `set_data(key, value)`: Updates a key in local memory and automatically persists it to SQLite via `save_storage()`.
|
|
195
195
|
3. `load_storage()`: Reloads fresh key-value pairs directly from SQLite into `self.storage`.
|
|
196
196
|
4. `save_storage()`: Writes all in-memory key-value pairs in `self.storage` back to SQLite.
|
|
197
|
-
5. `get_api_key(
|
|
197
|
+
5. `get_api_key(self, default=None)`: Fetches the specified API key from `flyshell_keys.env`.
|
|
198
198
|
|
|
199
199
|
Plugins save automatically on shut-down.
|
|
200
200
|
|
|
@@ -11,6 +11,8 @@ Result touch(const char *path);
|
|
|
11
11
|
|
|
12
12
|
Result list_dir(const char *path, DirList *out_list);
|
|
13
13
|
|
|
14
|
+
Result make_dir(const char *path, bool parents);
|
|
15
|
+
|
|
14
16
|
static PyObject *method_ping(PyObject *self, PyObject *args) {
|
|
15
17
|
return PyLong_FromLong(42);
|
|
16
18
|
}
|
|
@@ -86,11 +88,23 @@ static PyObject *method_dir(PyObject *self, PyObject *args) {
|
|
|
86
88
|
return Py_BuildValue("(iN)", (int)SUCCESS, py_list);
|
|
87
89
|
}
|
|
88
90
|
|
|
91
|
+
static PyObject *method_mkdir(PyObject *self, PyObject *args) {
|
|
92
|
+
const char *path;
|
|
93
|
+
int parents = 0;
|
|
94
|
+
if (!PyArg_ParseTuple(args, "s|p", &path, &parents)) {
|
|
95
|
+
return NULL;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
Result res = make_dir(path, parents != 0);
|
|
99
|
+
return Py_BuildValue("(is)", (int)res, "");
|
|
100
|
+
}
|
|
101
|
+
|
|
89
102
|
static PyMethodDef DiskopsMethods[] = {
|
|
90
103
|
{"ping", method_ping, METH_NOARGS, "Health check ping."},
|
|
91
104
|
{"cat", method_cat, METH_VARARGS, "Read file content natively."},
|
|
92
105
|
{"touch", method_touch, METH_VARARGS, "Touch or create file natively."},
|
|
93
106
|
{"dir", method_dir, METH_VARARGS, "List directory contents natively."},
|
|
107
|
+
{"mkdir", method_mkdir, METH_VARARGS, "Create directory natively."},
|
|
94
108
|
{NULL, NULL, 0, NULL},
|
|
95
109
|
};
|
|
96
110
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// c_src/diskops/posix/mkdir.c
|
|
2
|
+
|
|
3
|
+
#include "../shared/native_errors.h"
|
|
4
|
+
#include <errno.h>
|
|
5
|
+
#include <stdbool.h>
|
|
6
|
+
#include <stdlib.h>
|
|
7
|
+
#include <string.h>
|
|
8
|
+
#include <sys/stat.h>
|
|
9
|
+
|
|
10
|
+
static Result make_single_dir_posix(const char *path, bool ignore_existing) {
|
|
11
|
+
if (mkdir(path, 0777) == 0) {
|
|
12
|
+
return SUCCESS;
|
|
13
|
+
}
|
|
14
|
+
if (errno == EEXIST && ignore_existing) {
|
|
15
|
+
struct stat st;
|
|
16
|
+
if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
|
|
17
|
+
return SUCCESS;
|
|
18
|
+
}
|
|
19
|
+
return ERR_NOT_DIR;
|
|
20
|
+
}
|
|
21
|
+
return map_posix_errno(errno);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Result make_dir(const char *path, bool parents) {
|
|
25
|
+
if (!path || path[0] == '\0') {
|
|
26
|
+
return ERR_INVALID_PATH;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!parents) {
|
|
30
|
+
return make_single_dir_posix(path, false);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
char *copy = strdup(path);
|
|
34
|
+
if (!copy) {
|
|
35
|
+
return ERR_IO;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
size_t len = strlen(copy);
|
|
39
|
+
while (len > 1 && copy[len - 1] == '/') {
|
|
40
|
+
copy[--len] = '\0';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (size_t i = 1; i < len; ++i) {
|
|
44
|
+
if (copy[i] == '/') {
|
|
45
|
+
copy[i] = '\0';
|
|
46
|
+
Result res = make_single_dir_posix(copy, true);
|
|
47
|
+
if (res != SUCCESS) {
|
|
48
|
+
free(copy);
|
|
49
|
+
return res;
|
|
50
|
+
}
|
|
51
|
+
copy[i] = '/';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
Result final_res = make_single_dir_posix(copy, true);
|
|
56
|
+
free(copy);
|
|
57
|
+
return final_res;
|
|
58
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// c_src/diskops/win32/mkdir.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
|
+
static Result make_single_dir_win32(const wchar_t *wpath, bool ignore_existing) {
|
|
10
|
+
if (CreateDirectoryW(wpath, NULL) != 0) {
|
|
11
|
+
return SUCCESS;
|
|
12
|
+
}
|
|
13
|
+
DWORD err = GetLastError();
|
|
14
|
+
if (err == ERROR_ALREADY_EXISTS && ignore_existing) {
|
|
15
|
+
DWORD attrs = GetFileAttributesW(wpath);
|
|
16
|
+
if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY) != 0) {
|
|
17
|
+
return SUCCESS;
|
|
18
|
+
}
|
|
19
|
+
return ERR_NOT_DIR;
|
|
20
|
+
}
|
|
21
|
+
return map_win32_error(err);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Result make_dir(const char *path, bool parents) {
|
|
25
|
+
if (!path || path[0] == '\0') {
|
|
26
|
+
return ERR_INVALID_PATH;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
wchar_t *wpath = utf8_to_wide(path);
|
|
30
|
+
if (!wpath) {
|
|
31
|
+
return ERR_INVALID_PATH;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!parents) {
|
|
35
|
+
Result res = make_single_dir_win32(wpath, false);
|
|
36
|
+
free(wpath);
|
|
37
|
+
return res;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
size_t len = wcslen(wpath);
|
|
41
|
+
while (len > 1 && (wpath[len - 1] == L'\\' || wpath[len - 1] == L'/')) {
|
|
42
|
+
if (len == 3 && wpath[1] == L':') {
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
wpath[--len] = L'\0';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
size_t start = 1;
|
|
49
|
+
if (len >= 3 && wpath[1] == L':' && (wpath[2] == L'\\' || wpath[2] == L'/')) {
|
|
50
|
+
start = 3;
|
|
51
|
+
} else if (len >= 2 && (wpath[0] == L'\\' || wpath[0] == L'/') &&
|
|
52
|
+
(wpath[1] == L'\\' || wpath[1] == L'/')) {
|
|
53
|
+
start = 2;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
for (size_t i = start; i < len; ++i) {
|
|
57
|
+
if (wpath[i] == L'\\' || wpath[i] == L'/') {
|
|
58
|
+
wchar_t orig = wpath[i];
|
|
59
|
+
wpath[i] = L'\0';
|
|
60
|
+
Result res = make_single_dir_win32(wpath, true);
|
|
61
|
+
if (res != SUCCESS) {
|
|
62
|
+
free(wpath);
|
|
63
|
+
return res;
|
|
64
|
+
}
|
|
65
|
+
wpath[i] = orig;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Result final_res = make_single_dir_win32(wpath, true);
|
|
70
|
+
free(wpath);
|
|
71
|
+
return final_res;
|
|
72
|
+
}
|
|
@@ -11,10 +11,12 @@ sources = [
|
|
|
11
11
|
if sys.platform == "win32":
|
|
12
12
|
sources.append("c_src/diskops/win32/cat.c")
|
|
13
13
|
sources.append("c_src/diskops/win32/dir.c")
|
|
14
|
+
sources.append("c_src/diskops/win32/mkdir.c")
|
|
14
15
|
sources.append("c_src/diskops/win32/touch.c")
|
|
15
16
|
else:
|
|
16
17
|
sources.append("c_src/diskops/posix/cat.c")
|
|
17
18
|
sources.append("c_src/diskops/posix/dir.c")
|
|
19
|
+
sources.append("c_src/diskops/posix/mkdir.c")
|
|
18
20
|
sources.append("c_src/diskops/posix/touch.c")
|
|
19
21
|
|
|
20
22
|
native_diskops = Extension(
|
|
@@ -71,36 +71,6 @@ class Copy(BaseCmd):
|
|
|
71
71
|
return (1, f"\nSystem Error: Failed to copy '{raw_src}' ({e})\n")
|
|
72
72
|
|
|
73
73
|
|
|
74
|
-
class MkDir(BaseCmd):
|
|
75
|
-
name = "mkdir"
|
|
76
|
-
description = "Create a new directory from the current working directory"
|
|
77
|
-
min_args = 1
|
|
78
|
-
options = "Directory name"
|
|
79
|
-
aliases = ["md"]
|
|
80
|
-
|
|
81
|
-
def execute(self, args):
|
|
82
|
-
use_parents = ("-p" in args) or ("--parents" in args)
|
|
83
|
-
path_tokens = [arg for arg in args if arg not in ("-p", "--parents")]
|
|
84
|
-
target = " ".join(path_tokens).strip("\"'")
|
|
85
|
-
try:
|
|
86
|
-
if use_parents:
|
|
87
|
-
os.makedirs(target, exist_ok=True)
|
|
88
|
-
else:
|
|
89
|
-
os.mkdir(target)
|
|
90
|
-
return (0, f"\nSUCCESS! Created directory '{target}'\n")
|
|
91
|
-
except FileExistsError:
|
|
92
|
-
return (1, f"\nSystem Error: Directory '{target}' already exists.\n")
|
|
93
|
-
except FileNotFoundError:
|
|
94
|
-
return (
|
|
95
|
-
1,
|
|
96
|
-
"\nSystem Error: Parent directory does not exist. Use '-p' or '--parents' to create parent directories.\n",
|
|
97
|
-
)
|
|
98
|
-
except PermissionError:
|
|
99
|
-
return (1, f"\nSystem Error: Permission denied. Cannot create '{target}'\n")
|
|
100
|
-
except Exception as e:
|
|
101
|
-
return (1, f"\nSystem Error: Unable to create directory '{target}' ({e})\n")
|
|
102
|
-
|
|
103
|
-
|
|
104
74
|
class Move(BaseCmd):
|
|
105
75
|
name = "mv"
|
|
106
76
|
description = "Move or relocate files and directories"
|
|
@@ -90,6 +90,34 @@ class Dir(BaseCmd):
|
|
|
90
90
|
return (0, "\n".join(lines))
|
|
91
91
|
|
|
92
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):
|
|
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
|
+
|
|
93
121
|
class Touch(BaseCmd):
|
|
94
122
|
name = "touch"
|
|
95
123
|
description = "Create an empty file or update existing file timestamps"
|
|
@@ -47,6 +47,32 @@ def lgc_dir(target_path: Path) -> tuple[int, list[tuple[str, bool]]]:
|
|
|
47
47
|
return (-99, []) # ERR_UNKNOWN
|
|
48
48
|
|
|
49
49
|
|
|
50
|
+
def lgc_mkdir(target_path: Path, parents: bool = False) -> tuple[int, str]:
|
|
51
|
+
try:
|
|
52
|
+
if parents:
|
|
53
|
+
os.makedirs(target_path, exist_ok=True)
|
|
54
|
+
else:
|
|
55
|
+
os.mkdir(target_path)
|
|
56
|
+
return (0, "") # SUCCESS
|
|
57
|
+
except FileExistsError:
|
|
58
|
+
return (-5, "") # ERR_EXISTS
|
|
59
|
+
except NotADirectoryError:
|
|
60
|
+
return (-4, "") # ERR_NOT_DIR
|
|
61
|
+
except FileNotFoundError:
|
|
62
|
+
for parent in target_path.parents:
|
|
63
|
+
if parent.exists() and not parent.is_dir():
|
|
64
|
+
return (-4, "") # ERR_NOT_DIR
|
|
65
|
+
return (-1, "") # ERR_NOT_FOUND
|
|
66
|
+
except PermissionError:
|
|
67
|
+
return (-2, "") # ERR_PERMISSION
|
|
68
|
+
except OSError as e:
|
|
69
|
+
if getattr(e, "errno", None) == 28:
|
|
70
|
+
return (-12, "") # ERR_NO_SPACE
|
|
71
|
+
return (-13, "") # ERR_IO
|
|
72
|
+
except Exception:
|
|
73
|
+
return (-99, "") # ERR_UNKNOWN
|
|
74
|
+
|
|
75
|
+
|
|
50
76
|
def lgc_touch(target_path: Path) -> tuple[int, str]:
|
|
51
77
|
if target_path.is_dir():
|
|
52
78
|
return (-3, "") # ERR_IS_DIR
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flyshell
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.6
|
|
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.4.
|
|
26
|
+
> Documentation last updated: v1.4.5
|
|
27
27
|
|
|
28
28
|
A modular, zero-dependency command-line environment and extensible runtime interface built in Python with compiled C-extensions.
|
|
29
29
|
|
|
@@ -177,7 +177,7 @@ All plugins must have an entry-point file. For single-file plugins, this is the
|
|
|
177
177
|
This file is what enables Flyshell to speak to your plugin.
|
|
178
178
|
|
|
179
179
|
```python
|
|
180
|
-
# Entry-point (my_plugin.py or my_plugin
|
|
180
|
+
# Entry-point (my_plugin.py or my_plugin/plugin.py)
|
|
181
181
|
|
|
182
182
|
from flyshell import BasePlugin # This is required
|
|
183
183
|
|
|
@@ -186,11 +186,11 @@ class MyPlugin(BasePlugin):
|
|
|
186
186
|
description = "This is my plugin." # A short one-line explaining what your plugin does
|
|
187
187
|
version = "1.0.0" # Default is 1.0.0
|
|
188
188
|
author = "kianodev" # You can put your name, your GitHub handle, or leave blank to make it 'Unknown'
|
|
189
|
-
|
|
189
|
+
identifier = "" # (OPTIONAL) Alternative name for your plugin command (defaults to dir / file name)
|
|
190
190
|
usage = "" # (OPTIONAL) Explain how to use your plugin
|
|
191
191
|
extended_help = "" # (OPTIONAL) A more detailed, multi-line guide containing specific assistance
|
|
192
|
-
api_keys = [] # (OPTIONAL) Define any required key names here. Use get_api_key(key_name) to call the key. Please add all keys in CAPITALS
|
|
193
|
-
third_pty_libs = [] # (OPTIONAL) Define all required third party libraries / dependencies here. Use their Python import names as this is how Flyshell checks them
|
|
192
|
+
api_keys = [] # (OPTIONAL) Define any required key names here. Use get_api_key(key_name) to call the key. Please add all keys in CAPITALS
|
|
193
|
+
third_pty_libs = [] # (OPTIONAL) Define all required third party libraries / dependencies here. Use their Python import names as this is how Flyshell checks them
|
|
194
194
|
|
|
195
195
|
def on_load(self): # (OPTIONAL) Enables your program to handle specialist set-up tasks before execute()
|
|
196
196
|
pass
|
|
@@ -211,7 +211,7 @@ Additional functions are available for you to use:
|
|
|
211
211
|
2. `set_data(key, value)`: Updates a key in local memory and automatically persists it to SQLite via `save_storage()`.
|
|
212
212
|
3. `load_storage()`: Reloads fresh key-value pairs directly from SQLite into `self.storage`.
|
|
213
213
|
4. `save_storage()`: Writes all in-memory key-value pairs in `self.storage` back to SQLite.
|
|
214
|
-
5. `get_api_key(
|
|
214
|
+
5. `get_api_key(self, default=None)`: Fetches the specified API key from `flyshell_keys.env`.
|
|
215
215
|
|
|
216
216
|
Plugins save automatically on shut-down.
|
|
217
217
|
|
|
@@ -6,6 +6,7 @@ setup.py
|
|
|
6
6
|
c_src/diskops/diskops.c
|
|
7
7
|
c_src/diskops/posix/cat.c
|
|
8
8
|
c_src/diskops/posix/dir.c
|
|
9
|
+
c_src/diskops/posix/mkdir.c
|
|
9
10
|
c_src/diskops/posix/touch.c
|
|
10
11
|
c_src/diskops/shared/dir_types.c
|
|
11
12
|
c_src/diskops/shared/dir_types.h
|
|
@@ -13,6 +14,7 @@ c_src/diskops/shared/native_errors.h
|
|
|
13
14
|
c_src/diskops/shared/win32_utf.h
|
|
14
15
|
c_src/diskops/win32/cat.c
|
|
15
16
|
c_src/diskops/win32/dir.c
|
|
17
|
+
c_src/diskops/win32/mkdir.c
|
|
16
18
|
c_src/diskops/win32/touch.c
|
|
17
19
|
src/flyshell/__init__.py
|
|
18
20
|
src/flyshell/constants.py
|
|
@@ -11,27 +11,6 @@ def test_native_extension_loaded():
|
|
|
11
11
|
assert bridge._native.ping() == 42
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
def test_native_touch_creates_and_updates_file(tmp_path):
|
|
15
|
-
target = tmp_path / "native_touch.txt"
|
|
16
|
-
code, _ = bridge._native.touch(str(target))
|
|
17
|
-
assert code == 0
|
|
18
|
-
assert target.exists()
|
|
19
|
-
cmd = handler.Touch()
|
|
20
|
-
exit_code, msg = cmd.execute([str(target)])
|
|
21
|
-
assert exit_code == 0
|
|
22
|
-
assert "touched successfully" in msg
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def test_native_touch_errors(tmp_path):
|
|
26
|
-
missing_parent = tmp_path / "no_such_dir" / "file.txt"
|
|
27
|
-
code, _ = bridge._native.touch(str(missing_parent))
|
|
28
|
-
assert code == -1
|
|
29
|
-
cmd = handler.Touch()
|
|
30
|
-
exit_code, msg = cmd.execute([str(tmp_path)])
|
|
31
|
-
assert exit_code == 1
|
|
32
|
-
assert "Target is a directory, not a file" in msg
|
|
33
|
-
|
|
34
|
-
|
|
35
14
|
def test_native_cat_reads_and_formats_content(tmp_path):
|
|
36
15
|
file_path = tmp_path / "native_cat.txt"
|
|
37
16
|
file_path.write_text("alpha\nbeta\ngamma\ndelta\n", encoding="utf-8")
|
|
@@ -82,9 +61,64 @@ def test_native_dir_lists_entries_and_handles_errors(tmp_path):
|
|
|
82
61
|
assert "Target is not a directory" in msg
|
|
83
62
|
|
|
84
63
|
|
|
64
|
+
def test_native_mkdir_creates_and_handles_parents(tmp_path):
|
|
65
|
+
cmd = handler.MkDir()
|
|
66
|
+
target = tmp_path / "native_folder"
|
|
67
|
+
code, _ = bridge._native.mkdir(str(target), False)
|
|
68
|
+
assert code == 0
|
|
69
|
+
assert target.is_dir()
|
|
70
|
+
exit_code, msg = cmd.execute([str(target)])
|
|
71
|
+
assert exit_code == 1
|
|
72
|
+
assert "Item already exists" in msg
|
|
73
|
+
nested = tmp_path / "parent_dir" / "child_dir" / "leaf_dir"
|
|
74
|
+
exit_code, msg = cmd.execute([str(nested)])
|
|
75
|
+
assert exit_code == 1
|
|
76
|
+
assert "Parent directory does not exist" in msg
|
|
77
|
+
exit_code, msg = cmd.execute(["-p", str(nested)])
|
|
78
|
+
assert exit_code == 0
|
|
79
|
+
assert "Created directory" in msg
|
|
80
|
+
assert nested.is_dir()
|
|
81
|
+
exit_code, msg = cmd.execute(["--parents", str(nested)])
|
|
82
|
+
assert exit_code == 0
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_native_mkdir_errors(tmp_path):
|
|
86
|
+
regular_file = tmp_path / "blocker.txt"
|
|
87
|
+
regular_file.write_text("file", encoding="utf-8")
|
|
88
|
+
code, _ = bridge._native.mkdir(str(regular_file / "sub"), True)
|
|
89
|
+
assert code == -4
|
|
90
|
+
cmd = handler.MkDir()
|
|
91
|
+
exit_code, msg = cmd.execute(["-p"])
|
|
92
|
+
assert exit_code == 1
|
|
93
|
+
assert "Directory name not specified" in msg
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def test_native_touch_creates_and_updates_file(tmp_path):
|
|
97
|
+
target = tmp_path / "native_touch.txt"
|
|
98
|
+
code, _ = bridge._native.touch(str(target))
|
|
99
|
+
assert code == 0
|
|
100
|
+
assert target.exists()
|
|
101
|
+
cmd = handler.Touch()
|
|
102
|
+
exit_code, msg = cmd.execute([str(target)])
|
|
103
|
+
assert exit_code == 0
|
|
104
|
+
assert "touched successfully" in msg
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def test_native_touch_errors(tmp_path):
|
|
108
|
+
missing_parent = tmp_path / "no_such_dir" / "file.txt"
|
|
109
|
+
code, _ = bridge._native.touch(str(missing_parent))
|
|
110
|
+
assert code == -1
|
|
111
|
+
cmd = handler.Touch()
|
|
112
|
+
exit_code, msg = cmd.execute([str(tmp_path)])
|
|
113
|
+
assert exit_code == 1
|
|
114
|
+
assert "Target is a directory, not a file" in msg
|
|
115
|
+
|
|
116
|
+
|
|
85
117
|
def test_native_unicode_paths(tmp_path):
|
|
86
118
|
unicode_dir = tmp_path / "dir_日本語"
|
|
87
|
-
|
|
119
|
+
code, _ = bridge._native.mkdir(str(unicode_dir), False)
|
|
120
|
+
assert code == 0
|
|
121
|
+
assert unicode_dir.is_dir()
|
|
88
122
|
unicode_file = unicode_dir / "café_🚀.txt"
|
|
89
123
|
code, _ = bridge._native.touch(str(unicode_file))
|
|
90
124
|
assert code == 0
|
|
@@ -12,35 +12,6 @@ def force_legacy_backend(monkeypatch):
|
|
|
12
12
|
monkeypatch.setattr(bridge, "has_native_support", lambda: False)
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
def test_legacy_touch_creates_file_and_updates_timestamp(tmp_path):
|
|
16
|
-
cmd = handler.Touch()
|
|
17
|
-
target = tmp_path / "test.txt"
|
|
18
|
-
code, msg = cmd.execute([str(target)])
|
|
19
|
-
assert code == 0
|
|
20
|
-
assert "touched successfully" in msg
|
|
21
|
-
assert target.exists()
|
|
22
|
-
code, msg = cmd.execute([str(target)])
|
|
23
|
-
assert code == 0
|
|
24
|
-
assert "touched successfully" in msg
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def test_legacy_touch_missing_parent_directory(tmp_path):
|
|
28
|
-
cmd = handler.Touch()
|
|
29
|
-
target = tmp_path / "nonexistent_dir" / "test.txt"
|
|
30
|
-
code, msg = cmd.execute([str(target)])
|
|
31
|
-
assert code == 1
|
|
32
|
-
assert "File or path not found" in msg
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def test_legacy_touch_directory_error(tmp_path):
|
|
36
|
-
code, _ = legacy.lgc_touch(tmp_path)
|
|
37
|
-
assert code == -3 # ERR_IS_DIR
|
|
38
|
-
cmd = handler.Touch()
|
|
39
|
-
exit_code, msg = cmd.execute([str(tmp_path)])
|
|
40
|
-
assert exit_code == 1
|
|
41
|
-
assert "Target is a directory, not a file" in msg
|
|
42
|
-
|
|
43
|
-
|
|
44
15
|
def test_legacy_cat_reads_content_with_limit_and_numbers(tmp_path):
|
|
45
16
|
file_path = tmp_path / "sample.txt"
|
|
46
17
|
file_path.write_text("line 1\nline 2\nline 3\nline 4\n", encoding="utf-8")
|
|
@@ -82,3 +53,62 @@ def test_legacy_dir_lists_files_and_handles_errors(tmp_path):
|
|
|
82
53
|
code, msg = cmd.execute([str(tmp_path / "beta.txt")])
|
|
83
54
|
assert code == 1
|
|
84
55
|
assert "Target is not a directory" in msg
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_legacy_mkdir_creates_and_handles_parents(tmp_path):
|
|
59
|
+
cmd = handler.MkDir()
|
|
60
|
+
target = tmp_path / "legacy_folder"
|
|
61
|
+
exit_code, msg = cmd.execute([str(target)])
|
|
62
|
+
assert exit_code == 0
|
|
63
|
+
assert "Created directory" in msg
|
|
64
|
+
assert target.is_dir()
|
|
65
|
+
exit_code, msg = cmd.execute([str(target)])
|
|
66
|
+
assert exit_code == 1
|
|
67
|
+
assert "Item already exists" in msg
|
|
68
|
+
nested = tmp_path / "parent_dir" / "child_dir"
|
|
69
|
+
exit_code, msg = cmd.execute([str(nested)])
|
|
70
|
+
assert exit_code == 1
|
|
71
|
+
assert "Parent directory does not exist" in msg
|
|
72
|
+
exit_code, msg = cmd.execute(["-p", str(nested)])
|
|
73
|
+
assert exit_code == 0
|
|
74
|
+
assert nested.is_dir()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_legacy_mkdir_errors(tmp_path):
|
|
78
|
+
regular_file = tmp_path / "blocker.txt"
|
|
79
|
+
regular_file.write_text("file", encoding="utf-8")
|
|
80
|
+
code, _ = legacy.lgc_mkdir(regular_file / "sub", parents=True)
|
|
81
|
+
assert code == -4 # ERR_NOT_DIR
|
|
82
|
+
cmd = handler.MkDir()
|
|
83
|
+
exit_code, msg = cmd.execute(["--parents"])
|
|
84
|
+
assert exit_code == 1
|
|
85
|
+
assert "Directory name not specified" in msg
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_legacy_touch_creates_file_and_updates_timestamp(tmp_path):
|
|
89
|
+
cmd = handler.Touch()
|
|
90
|
+
target = tmp_path / "test.txt"
|
|
91
|
+
code, msg = cmd.execute([str(target)])
|
|
92
|
+
assert code == 0
|
|
93
|
+
assert "touched successfully" in msg
|
|
94
|
+
assert target.exists()
|
|
95
|
+
code, msg = cmd.execute([str(target)])
|
|
96
|
+
assert code == 0
|
|
97
|
+
assert "touched successfully" in msg
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def test_legacy_touch_missing_parent_directory(tmp_path):
|
|
101
|
+
cmd = handler.Touch()
|
|
102
|
+
target = tmp_path / "nonexistent_dir" / "test.txt"
|
|
103
|
+
code, msg = cmd.execute([str(target)])
|
|
104
|
+
assert code == 1
|
|
105
|
+
assert "File or path not found" in msg
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def test_legacy_touch_directory_error(tmp_path):
|
|
109
|
+
code, _ = legacy.lgc_touch(tmp_path)
|
|
110
|
+
assert code == -3 # ERR_IS_DIR
|
|
111
|
+
cmd = handler.Touch()
|
|
112
|
+
exit_code, msg = cmd.execute([str(tmp_path)])
|
|
113
|
+
assert exit_code == 1
|
|
114
|
+
assert "Target is a directory, not a file" in msg
|
|
@@ -3,21 +3,6 @@
|
|
|
3
3
|
from flyshell.builtin import diskops
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
def test_mkdir_standard_and_parents(tmp_path):
|
|
7
|
-
cmd = diskops.MkDir()
|
|
8
|
-
target = tmp_path / "new_folder"
|
|
9
|
-
code, msg = cmd.execute([str(target)])
|
|
10
|
-
assert code == 0
|
|
11
|
-
assert target.is_dir()
|
|
12
|
-
code, msg = cmd.execute([str(target)])
|
|
13
|
-
assert code == 1
|
|
14
|
-
assert "already exists" in msg
|
|
15
|
-
nested = tmp_path / "parent" / "child"
|
|
16
|
-
code, msg = cmd.execute(["-p", str(nested)])
|
|
17
|
-
assert code == 0
|
|
18
|
-
assert nested.is_dir()
|
|
19
|
-
|
|
20
|
-
|
|
21
6
|
def test_rename_file(tmp_path):
|
|
22
7
|
src = tmp_path / "old.txt"
|
|
23
8
|
src.write_text("data")
|
|
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
|
|
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
|