flyshell 1.4.3__tar.gz → 1.4.5__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.3/src/flyshell.egg-info → flyshell-1.4.5}/PKG-INFO +7 -7
- {flyshell-1.4.3 → flyshell-1.4.5}/README.md +6 -6
- {flyshell-1.4.3 → flyshell-1.4.5}/c_src/diskops/diskops.c +8 -1
- flyshell-1.4.5/c_src/diskops/posix/cat.c +86 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/c_src/diskops/posix/dir.c +9 -2
- {flyshell-1.4.3 → flyshell-1.4.5}/c_src/diskops/posix/touch.c +9 -7
- flyshell-1.4.5/c_src/diskops/win32/cat.c +96 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/constants.py +2 -2
- {flyshell-1.4.3 → flyshell-1.4.5/src/flyshell.egg-info}/PKG-INFO +7 -7
- {flyshell-1.4.3 → flyshell-1.4.5}/tests/test_diskops_ext.py +24 -1
- flyshell-1.4.3/c_src/diskops/posix/cat.c +0 -58
- flyshell-1.4.3/c_src/diskops/win32/cat.c +0 -70
- {flyshell-1.4.3 → flyshell-1.4.5}/LICENSE +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/MANIFEST.in +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/c_src/diskops/shared/dir_types.c +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/c_src/diskops/shared/dir_types.h +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/c_src/diskops/shared/native_errors.h +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/c_src/diskops/shared/win32_utf.h +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/c_src/diskops/win32/dir.c +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/c_src/diskops/win32/touch.c +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/pyproject.toml +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/setup.cfg +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/setup.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/__init__.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/abstract/__init__.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/abstract/base_cmd.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/abstract/base_plugin.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/abstract/parent_cmd.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/accounts/__init__.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/accounts/auth.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/bin/__init__.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/builtin/__init__.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/builtin/diskops.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/builtin/fs.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/builtin/pkg.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/builtin/system.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/builtin/utils.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/core/__init__.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/core/console.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/core/data.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/core/directory.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/main.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/native/__init__.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/native/diskops_bridge.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/native/diskops_handler.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/native/legacy/__init__.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/native/legacy/diskops.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/startup/__init__.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/startup/deps.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/startup/env.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell/startup/loader.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell.egg-info/SOURCES.txt +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell.egg-info/dependency_links.txt +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell.egg-info/entry_points.txt +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell.egg-info/requires.txt +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/src/flyshell.egg-info/top_level.txt +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/tests/test_auth.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/tests/test_data.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/tests/test_deps.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/tests/test_directory.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/tests/test_diskops_lgc.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/tests/test_diskops_old.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/tests/test_env.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/tests/test_fs.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/tests/test_loader.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/tests/test_pkg.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/tests/test_security.py +0 -0
- {flyshell-1.4.3 → flyshell-1.4.5}/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.5
|
|
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
|
|
|
@@ -65,6 +65,7 @@ static PyObject *method_dir(PyObject *self, PyObject *args) {
|
|
|
65
65
|
|
|
66
66
|
PyObject *py_list = PyList_New((Py_ssize_t)dir_list.count);
|
|
67
67
|
if (!py_list) {
|
|
68
|
+
PyErr_Clear();
|
|
68
69
|
free_dir_list(&dir_list);
|
|
69
70
|
return Py_BuildValue("(i[])", (int)ERR_IO);
|
|
70
71
|
}
|
|
@@ -72,7 +73,13 @@ static PyObject *method_dir(PyObject *self, PyObject *args) {
|
|
|
72
73
|
for (size_t i = 0; i < dir_list.count; ++i) {
|
|
73
74
|
PyObject *item = Py_BuildValue("(sO)", dir_list.entries[i].name,
|
|
74
75
|
dir_list.entries[i].is_dir ? Py_True : Py_False);
|
|
75
|
-
|
|
76
|
+
if (!item) {
|
|
77
|
+
PyErr_Clear();
|
|
78
|
+
Py_DECREF(py_list);
|
|
79
|
+
free_dir_list(&dir_list);
|
|
80
|
+
return Py_BuildValue("(i[])", (int)ERR_DECODE);
|
|
81
|
+
}
|
|
82
|
+
PyList_SET_ITEM(py_list, (Py_ssize_t)i, item);
|
|
76
83
|
}
|
|
77
84
|
|
|
78
85
|
free_dir_list(&dir_list);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// c_src/diskops/posix/cat.c
|
|
2
|
+
|
|
3
|
+
#include "../shared/native_errors.h"
|
|
4
|
+
#include <errno.h>
|
|
5
|
+
#include <fcntl.h>
|
|
6
|
+
#include <stdlib.h>
|
|
7
|
+
#include <sys/stat.h>
|
|
8
|
+
#include <unistd.h>
|
|
9
|
+
|
|
10
|
+
#define CAT_CHUNK_SIZE 32768
|
|
11
|
+
|
|
12
|
+
Result cat(const char *path, char **out_buf, size_t *out_size) {
|
|
13
|
+
if (!path || !out_buf || !out_size) {
|
|
14
|
+
return ERR_INVALID_PATH;
|
|
15
|
+
}
|
|
16
|
+
*out_buf = NULL;
|
|
17
|
+
*out_size = 0;
|
|
18
|
+
|
|
19
|
+
int fd = open(path, O_RDONLY);
|
|
20
|
+
if (fd < 0) {
|
|
21
|
+
return map_posix_errno(errno);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
struct stat st;
|
|
25
|
+
if (fstat(fd, &st) < 0) {
|
|
26
|
+
int err = errno;
|
|
27
|
+
close(fd);
|
|
28
|
+
return map_posix_errno(err);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (S_ISDIR(st.st_mode)) {
|
|
32
|
+
close(fd);
|
|
33
|
+
return ERR_IS_DIR;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
size_t capacity = (st.st_size > 0) ? ((size_t)st.st_size + 1) : CAT_CHUNK_SIZE;
|
|
37
|
+
char *buf = (char *)malloc(capacity);
|
|
38
|
+
if (!buf) {
|
|
39
|
+
close(fd);
|
|
40
|
+
return ERR_IO;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
size_t total_read = 0;
|
|
44
|
+
for (;;) {
|
|
45
|
+
if (total_read + CAT_CHUNK_SIZE + 1 > capacity) {
|
|
46
|
+
size_t new_cap = capacity * 2;
|
|
47
|
+
if (new_cap < total_read + CAT_CHUNK_SIZE + 1) {
|
|
48
|
+
new_cap = total_read + CAT_CHUNK_SIZE + 1;
|
|
49
|
+
}
|
|
50
|
+
char *resized = (char *)realloc(buf, new_cap);
|
|
51
|
+
if (!resized) {
|
|
52
|
+
close(fd);
|
|
53
|
+
free(buf);
|
|
54
|
+
return ERR_IO;
|
|
55
|
+
}
|
|
56
|
+
buf = resized;
|
|
57
|
+
capacity = new_cap;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
ssize_t n = read(fd, buf + total_read, CAT_CHUNK_SIZE);
|
|
61
|
+
if (n < 0) {
|
|
62
|
+
if (errno == EINTR) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
int read_err = errno;
|
|
66
|
+
close(fd);
|
|
67
|
+
free(buf);
|
|
68
|
+
return map_posix_errno(read_err);
|
|
69
|
+
}
|
|
70
|
+
if (n == 0) {
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
total_read += (size_t)n;
|
|
74
|
+
}
|
|
75
|
+
close(fd);
|
|
76
|
+
|
|
77
|
+
if (total_read == 0) {
|
|
78
|
+
free(buf);
|
|
79
|
+
return ERR_EMPTY;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
buf[total_read] = '\0';
|
|
83
|
+
*out_buf = buf;
|
|
84
|
+
*out_size = total_read;
|
|
85
|
+
return SUCCESS;
|
|
86
|
+
}
|
|
@@ -50,7 +50,7 @@ Result list_dir(const char *path, DirList *out_list) {
|
|
|
50
50
|
|
|
51
51
|
bool is_dir = false;
|
|
52
52
|
#ifdef _DIRENT_HAVE_D_TYPE
|
|
53
|
-
if (entry->d_type != DT_UNKNOWN) {
|
|
53
|
+
if (entry->d_type != DT_UNKNOWN && entry->d_type != DT_LNK) {
|
|
54
54
|
is_dir = (entry->d_type == DT_DIR);
|
|
55
55
|
} else
|
|
56
56
|
#endif
|
|
@@ -61,7 +61,14 @@ Result list_dir(const char *path, DirList *out_list) {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
char *name_copy = strdup(entry->d_name);
|
|
65
|
+
if (!name_copy) {
|
|
66
|
+
closedir(dir);
|
|
67
|
+
free_dir_list(out_list);
|
|
68
|
+
return ERR_IO;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
out_list->entries[out_list->count].name = name_copy;
|
|
65
72
|
out_list->entries[out_list->count].is_dir = is_dir;
|
|
66
73
|
out_list->count++;
|
|
67
74
|
}
|
|
@@ -15,16 +15,18 @@ Result touch(const char *path) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
struct stat st;
|
|
18
|
-
if (stat(path, &st) == 0) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return map_posix_errno(errno);
|
|
24
|
-
}
|
|
18
|
+
if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
|
|
19
|
+
return ERR_IS_DIR;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (utimensat(AT_FDCWD, path, NULL, 0) == 0) {
|
|
25
23
|
return SUCCESS;
|
|
26
24
|
}
|
|
27
25
|
|
|
26
|
+
if (errno != ENOENT) {
|
|
27
|
+
return map_posix_errno(errno);
|
|
28
|
+
}
|
|
29
|
+
|
|
28
30
|
int fd = open(path, O_WRONLY | O_CREAT | O_NONBLOCK | O_NOCTTY, 0666);
|
|
29
31
|
if (fd < 0) {
|
|
30
32
|
return map_posix_errno(errno);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// c_src/diskops/win32/cat.c
|
|
2
|
+
|
|
3
|
+
#include "../shared/native_errors.h"
|
|
4
|
+
#include "../shared/win32_utf.h"
|
|
5
|
+
#include <stdlib.h>
|
|
6
|
+
#include <windows.h>
|
|
7
|
+
|
|
8
|
+
#define CAT_CHUNK_SIZE 32768
|
|
9
|
+
|
|
10
|
+
Result cat(const char *path, char **out_buf, size_t *out_size) {
|
|
11
|
+
if (!path || !out_buf || !out_size) {
|
|
12
|
+
return ERR_INVALID_PATH;
|
|
13
|
+
}
|
|
14
|
+
*out_buf = NULL;
|
|
15
|
+
*out_size = 0;
|
|
16
|
+
|
|
17
|
+
wchar_t *wpath = utf8_to_wide(path);
|
|
18
|
+
if (!wpath) {
|
|
19
|
+
return ERR_INVALID_PATH;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
HANDLE hFile =
|
|
23
|
+
CreateFileW(wpath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
|
24
|
+
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
25
|
+
|
|
26
|
+
if (hFile == INVALID_HANDLE_VALUE) {
|
|
27
|
+
DWORD err = GetLastError();
|
|
28
|
+
if (err == ERROR_ACCESS_DENIED) {
|
|
29
|
+
DWORD attrs = GetFileAttributesW(wpath);
|
|
30
|
+
if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) {
|
|
31
|
+
free(wpath);
|
|
32
|
+
return ERR_IS_DIR;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
free(wpath);
|
|
36
|
+
return map_win32_error(err);
|
|
37
|
+
}
|
|
38
|
+
free(wpath);
|
|
39
|
+
|
|
40
|
+
LARGE_INTEGER size;
|
|
41
|
+
size_t capacity = CAT_CHUNK_SIZE;
|
|
42
|
+
if (GetFileSizeEx(hFile, &size) && size.QuadPart > 0) {
|
|
43
|
+
if ((ULONGLONG)size.QuadPart > (ULONGLONG)(SIZE_MAX - 1)) {
|
|
44
|
+
CloseHandle(hFile);
|
|
45
|
+
return ERR_IO;
|
|
46
|
+
}
|
|
47
|
+
capacity = (size_t)size.QuadPart + 1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
char *buf = (char *)malloc(capacity);
|
|
51
|
+
if (!buf) {
|
|
52
|
+
CloseHandle(hFile);
|
|
53
|
+
return ERR_IO;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
size_t total_read = 0;
|
|
57
|
+
for (;;) {
|
|
58
|
+
if (total_read + CAT_CHUNK_SIZE + 1 > capacity) {
|
|
59
|
+
size_t new_cap = capacity * 2;
|
|
60
|
+
if (new_cap < total_read + CAT_CHUNK_SIZE + 1) {
|
|
61
|
+
new_cap = total_read + CAT_CHUNK_SIZE + 1;
|
|
62
|
+
}
|
|
63
|
+
char *resized = (char *)realloc(buf, new_cap);
|
|
64
|
+
if (!resized) {
|
|
65
|
+
CloseHandle(hFile);
|
|
66
|
+
free(buf);
|
|
67
|
+
return ERR_IO;
|
|
68
|
+
}
|
|
69
|
+
buf = resized;
|
|
70
|
+
capacity = new_cap;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
DWORD bytes_read = 0;
|
|
74
|
+
if (!ReadFile(hFile, buf + total_read, CAT_CHUNK_SIZE, &bytes_read, NULL)) {
|
|
75
|
+
DWORD read_err = GetLastError();
|
|
76
|
+
CloseHandle(hFile);
|
|
77
|
+
free(buf);
|
|
78
|
+
return map_win32_error(read_err);
|
|
79
|
+
}
|
|
80
|
+
if (bytes_read == 0) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
total_read += (size_t)bytes_read;
|
|
84
|
+
}
|
|
85
|
+
CloseHandle(hFile);
|
|
86
|
+
|
|
87
|
+
if (total_read == 0) {
|
|
88
|
+
free(buf);
|
|
89
|
+
return ERR_EMPTY;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
buf[total_read] = '\0';
|
|
93
|
+
*out_buf = buf;
|
|
94
|
+
*out_size = total_read;
|
|
95
|
+
return SUCCESS;
|
|
96
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flyshell
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.5
|
|
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
|
|
|
@@ -62,7 +62,8 @@ def test_native_cat_errors(tmp_path):
|
|
|
62
62
|
|
|
63
63
|
def test_native_dir_lists_entries_and_handles_errors(tmp_path):
|
|
64
64
|
(tmp_path / "folder_a").mkdir()
|
|
65
|
-
|
|
65
|
+
file_b = tmp_path / "file_b.txt"
|
|
66
|
+
file_b.write_text("hello", encoding="utf-8")
|
|
66
67
|
code, items = bridge._native.dir(str(tmp_path))
|
|
67
68
|
assert code == 0
|
|
68
69
|
assert ("folder_a", True) in items
|
|
@@ -76,3 +77,25 @@ def test_native_dir_lists_entries_and_handles_errors(tmp_path):
|
|
|
76
77
|
exit_code, msg = cmd.execute([str(tmp_path / "does_not_exist")])
|
|
77
78
|
assert exit_code == 1
|
|
78
79
|
assert "File or path not found" in msg
|
|
80
|
+
exit_code, msg = cmd.execute([str(file_b)])
|
|
81
|
+
assert exit_code == 1
|
|
82
|
+
assert "Target is not a directory" in msg
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_native_unicode_paths(tmp_path):
|
|
86
|
+
unicode_dir = tmp_path / "dir_日本語"
|
|
87
|
+
unicode_dir.mkdir()
|
|
88
|
+
unicode_file = unicode_dir / "café_🚀.txt"
|
|
89
|
+
code, _ = bridge._native.touch(str(unicode_file))
|
|
90
|
+
assert code == 0
|
|
91
|
+
assert unicode_file.exists()
|
|
92
|
+
unicode_file.write_text("héllo 🌍\n", encoding="utf-8", newline="\n")
|
|
93
|
+
code, content = bridge._native.cat(str(unicode_file))
|
|
94
|
+
assert code == 0
|
|
95
|
+
assert content == "héllo 🌍\n"
|
|
96
|
+
code, items = bridge._native.dir(str(tmp_path))
|
|
97
|
+
assert code == 0
|
|
98
|
+
assert ("dir_日本語", True) in items
|
|
99
|
+
code, sub_items = bridge._native.dir(str(unicode_dir))
|
|
100
|
+
assert code == 0
|
|
101
|
+
assert ("café_🚀.txt", False) in sub_items
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// c_src/diskops/posix/cat.c
|
|
2
|
-
|
|
3
|
-
#include "../shared/native_errors.h"
|
|
4
|
-
#include <errno.h>
|
|
5
|
-
#include <fcntl.h>
|
|
6
|
-
#include <stdlib.h>
|
|
7
|
-
#include <sys/stat.h>
|
|
8
|
-
#include <unistd.h>
|
|
9
|
-
|
|
10
|
-
Result cat(const char *path, char **out_buf, size_t *out_size) {
|
|
11
|
-
if (!path || !out_buf || !out_size) {
|
|
12
|
-
return ERR_INVALID_PATH;
|
|
13
|
-
}
|
|
14
|
-
*out_buf = NULL;
|
|
15
|
-
*out_size = 0;
|
|
16
|
-
|
|
17
|
-
int fd = open(path, O_RDONLY);
|
|
18
|
-
if (fd < 0) {
|
|
19
|
-
return map_posix_errno(errno);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
struct stat st;
|
|
23
|
-
if (fstat(fd, &st) < 0) {
|
|
24
|
-
int err = errno;
|
|
25
|
-
close(fd);
|
|
26
|
-
return map_posix_errno(err);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (S_ISDIR(st.st_mode)) {
|
|
30
|
-
close(fd);
|
|
31
|
-
return ERR_IS_DIR;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (st.st_size == 0) {
|
|
35
|
-
close(fd);
|
|
36
|
-
return ERR_EMPTY;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
char *buf = (char *)malloc(st.st_size + 1);
|
|
40
|
-
if (!buf) {
|
|
41
|
-
close(fd);
|
|
42
|
-
return ERR_IO;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
ssize_t n = read(fd, buf, st.st_size);
|
|
46
|
-
int read_err = errno;
|
|
47
|
-
close(fd);
|
|
48
|
-
|
|
49
|
-
if (n < 0) {
|
|
50
|
-
free(buf);
|
|
51
|
-
return map_posix_errno(read_err);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
buf[n] = '\0';
|
|
55
|
-
*out_buf = buf;
|
|
56
|
-
*out_size = (size_t)n;
|
|
57
|
-
return SUCCESS;
|
|
58
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// c_src/diskops/win32/cat.c
|
|
2
|
-
|
|
3
|
-
#include "../shared/native_errors.h"
|
|
4
|
-
#include "../shared/win32_utf.h"
|
|
5
|
-
#include <stdlib.h>
|
|
6
|
-
#include <windows.h>
|
|
7
|
-
|
|
8
|
-
Result cat(const char *path, char **out_buf, size_t *out_size) {
|
|
9
|
-
if (!path || !out_buf || !out_size) {
|
|
10
|
-
return ERR_INVALID_PATH;
|
|
11
|
-
}
|
|
12
|
-
*out_buf = NULL;
|
|
13
|
-
*out_size = 0;
|
|
14
|
-
|
|
15
|
-
wchar_t *wpath = utf8_to_wide(path);
|
|
16
|
-
if (!wpath) {
|
|
17
|
-
return ERR_INVALID_PATH;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
HANDLE hFile =
|
|
21
|
-
CreateFileW(wpath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
|
22
|
-
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
23
|
-
|
|
24
|
-
if (hFile == INVALID_HANDLE_VALUE) {
|
|
25
|
-
DWORD err = GetLastError();
|
|
26
|
-
if (err == ERROR_ACCESS_DENIED) {
|
|
27
|
-
DWORD attrs = GetFileAttributesW(wpath);
|
|
28
|
-
if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) {
|
|
29
|
-
free(wpath);
|
|
30
|
-
return ERR_IS_DIR;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
free(wpath);
|
|
34
|
-
return map_win32_error(err);
|
|
35
|
-
}
|
|
36
|
-
free(wpath);
|
|
37
|
-
|
|
38
|
-
LARGE_INTEGER size;
|
|
39
|
-
if (!GetFileSizeEx(hFile, &size)) {
|
|
40
|
-
DWORD err = GetLastError();
|
|
41
|
-
CloseHandle(hFile);
|
|
42
|
-
return map_win32_error(err);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (size.QuadPart == 0) {
|
|
46
|
-
CloseHandle(hFile);
|
|
47
|
-
return ERR_EMPTY;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
char *buf = (char *)malloc(size.QuadPart + 1);
|
|
51
|
-
if (!buf) {
|
|
52
|
-
CloseHandle(hFile);
|
|
53
|
-
return ERR_IO;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
DWORD bytes_read = 0;
|
|
57
|
-
BOOL ok = ReadFile(hFile, buf, (DWORD)size.QuadPart, &bytes_read, NULL);
|
|
58
|
-
DWORD read_err = GetLastError();
|
|
59
|
-
CloseHandle(hFile);
|
|
60
|
-
|
|
61
|
-
if (!ok) {
|
|
62
|
-
free(buf);
|
|
63
|
-
return map_win32_error(read_err);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
buf[bytes_read] = '\0';
|
|
67
|
-
*out_buf = buf;
|
|
68
|
-
*out_size = (size_t)bytes_read;
|
|
69
|
-
return SUCCESS;
|
|
70
|
-
}
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|