flyshell 1.3.9__tar.gz → 1.3.11__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.
Files changed (63) hide show
  1. {flyshell-1.3.9/src/flyshell.egg-info → flyshell-1.3.11}/PKG-INFO +1 -1
  2. {flyshell-1.3.9 → flyshell-1.3.11}/c_src/diskops/diskops.c +32 -0
  3. flyshell-1.3.11/c_src/diskops/posix/dir.c +71 -0
  4. flyshell-1.3.11/c_src/diskops/shared/dir_types.c +16 -0
  5. flyshell-1.3.11/c_src/diskops/shared/dir_types.h +21 -0
  6. flyshell-1.3.11/c_src/diskops/win32/dir.c +65 -0
  7. {flyshell-1.3.9 → flyshell-1.3.11}/setup.py +3 -0
  8. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/builtin/diskops.py +0 -23
  9. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/constants.py +2 -2
  10. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/core/directory.py +1 -1
  11. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/native/diskops_handler.py +29 -1
  12. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/native/legacy/diskops.py +27 -2
  13. {flyshell-1.3.9 → flyshell-1.3.11/src/flyshell.egg-info}/PKG-INFO +1 -1
  14. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell.egg-info/SOURCES.txt +5 -1
  15. flyshell-1.3.9/tests/test_diskops.py → flyshell-1.3.11/tests/test_diskops_old.py +1 -56
  16. {flyshell-1.3.9 → flyshell-1.3.11}/LICENSE +0 -0
  17. {flyshell-1.3.9 → flyshell-1.3.11}/MANIFEST.in +0 -0
  18. {flyshell-1.3.9 → flyshell-1.3.11}/README.md +0 -0
  19. {flyshell-1.3.9 → flyshell-1.3.11}/c_src/diskops/posix/cat.c +0 -0
  20. {flyshell-1.3.9 → flyshell-1.3.11}/c_src/diskops/posix/touch.c +0 -0
  21. {flyshell-1.3.9 → flyshell-1.3.11}/c_src/diskops/shared/native_errors.h +0 -0
  22. {flyshell-1.3.9 → flyshell-1.3.11}/c_src/diskops/win32/cat.c +0 -0
  23. {flyshell-1.3.9 → flyshell-1.3.11}/c_src/diskops/win32/touch.c +0 -0
  24. {flyshell-1.3.9 → flyshell-1.3.11}/pyproject.toml +0 -0
  25. {flyshell-1.3.9 → flyshell-1.3.11}/setup.cfg +0 -0
  26. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/__init__.py +0 -0
  27. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/abstract/__init__.py +0 -0
  28. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/abstract/base_cmd.py +0 -0
  29. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/abstract/base_plugin.py +0 -0
  30. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/abstract/parent_cmd.py +0 -0
  31. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/accounts/__init__.py +0 -0
  32. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/accounts/auth.py +0 -0
  33. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/bin/__init__.py +0 -0
  34. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/builtin/__init__.py +0 -0
  35. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/builtin/fs.py +0 -0
  36. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/builtin/pkg.py +0 -0
  37. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/builtin/system.py +0 -0
  38. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/builtin/utils.py +0 -0
  39. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/core/__init__.py +0 -0
  40. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/core/console.py +0 -0
  41. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/core/data.py +0 -0
  42. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/main.py +0 -0
  43. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/native/__init__.py +0 -0
  44. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/native/diskops_bridge.py +0 -0
  45. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/native/legacy/__init__.py +0 -0
  46. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/startup/__init__.py +0 -0
  47. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/startup/deps.py +0 -0
  48. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/startup/env.py +0 -0
  49. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell/startup/loader.py +0 -0
  50. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell.egg-info/dependency_links.txt +0 -0
  51. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell.egg-info/entry_points.txt +0 -0
  52. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell.egg-info/requires.txt +0 -0
  53. {flyshell-1.3.9 → flyshell-1.3.11}/src/flyshell.egg-info/top_level.txt +0 -0
  54. {flyshell-1.3.9 → flyshell-1.3.11}/tests/test_auth.py +0 -0
  55. {flyshell-1.3.9 → flyshell-1.3.11}/tests/test_data.py +0 -0
  56. {flyshell-1.3.9 → flyshell-1.3.11}/tests/test_deps.py +0 -0
  57. {flyshell-1.3.9 → flyshell-1.3.11}/tests/test_directory.py +0 -0
  58. {flyshell-1.3.9 → flyshell-1.3.11}/tests/test_env.py +0 -0
  59. {flyshell-1.3.9 → flyshell-1.3.11}/tests/test_fs.py +0 -0
  60. {flyshell-1.3.9 → flyshell-1.3.11}/tests/test_loader.py +0 -0
  61. {flyshell-1.3.9 → flyshell-1.3.11}/tests/test_pkg.py +0 -0
  62. {flyshell-1.3.9 → flyshell-1.3.11}/tests/test_security.py +0 -0
  63. {flyshell-1.3.9 → flyshell-1.3.11}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flyshell
3
- Version: 1.3.9
3
+ Version: 1.3.11
4
4
  Summary: A modular, zero-dependency command-line environment in Python.
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.10
@@ -3,11 +3,14 @@
3
3
  #define PY_SSIZE_T_CLEAN
4
4
  #include <Python.h>
5
5
  #include "shared/native_errors.h"
6
+ #include "shared/dir_types.h"
6
7
 
7
8
  Result cat(const char* path, char** out_buf, size_t* out_size);
8
9
 
9
10
  Result touch(const char* path);
10
11
 
12
+ Result list_dir(const char* path, DirList* out_list);
13
+
11
14
  static PyObject* method_ping(PyObject* self, PyObject* args) {
12
15
  return PyLong_FromLong(42);
13
16
  }
@@ -48,10 +51,39 @@ static PyObject* method_touch(PyObject* self, PyObject* args) {
48
51
  return Py_BuildValue("(is)", (int)res, "");
49
52
  }
50
53
 
54
+ static PyObject* method_dir(PyObject* self, PyObject* args) {
55
+ const char* path;
56
+ if (!PyArg_ParseTuple(args, "s", &path)) {
57
+ return NULL;
58
+ }
59
+
60
+ DirList dir_list;
61
+ Result res = list_dir(path, &dir_list);
62
+ if (res != SUCCESS) {
63
+ return Py_BuildValue("(i[])", (int)res);
64
+ }
65
+
66
+ PyObject* py_list = PyList_New(dir_list.count);
67
+ if (!py_list) {
68
+ free_dir_list(&dir_list);
69
+ return Py_BuildValue("(i[])", (int)ERR_IO);
70
+ }
71
+
72
+ for (size_t i = 0; i < dir_list.count; ++i) {
73
+ PyObject* item = Py_BuildValue("(sO)", dir_list.entries[i].name,
74
+ dir_list.entries[i].is_dir ? Py_True : Py_False);
75
+ PyList_SET_ITEM(py_list, i, item);
76
+ }
77
+
78
+ free_dir_list(&dir_list);
79
+ return Py_BuildValue("(iN)", (int)SUCCESS, py_list);
80
+ }
81
+
51
82
  static PyMethodDef DiskopsMethods[] = {
52
83
  {"ping", method_ping, METH_NOARGS, "Health check ping."},
53
84
  {"cat", method_cat, METH_VARARGS, "Read file content natively."},
54
85
  {"touch", method_touch, METH_VARARGS, "Touch or create file natively."},
86
+ {"dir", method_dir, METH_VARARGS, "List directory contents natively."},
55
87
  {NULL, NULL, 0, NULL},
56
88
  };
57
89
 
@@ -0,0 +1,71 @@
1
+ // c_src/diskops/posix/dir.c
2
+
3
+ #define _POSIX_C_SOURCE 200809L
4
+ #define _GNU_SOURCE
5
+
6
+ #include <dirent.h>
7
+ #include <sys/stat.h>
8
+ #include <stdlib.h>
9
+ #include <string.h>
10
+ #include <errno.h>
11
+ #include "../shared/native_errors.h"
12
+ #include "../shared/dir_types.h"
13
+
14
+ Result list_dir(const char* path, DirList* out_list) {
15
+ if (!path || path[0] == '\0' || !out_list) {
16
+ return ERR_INVALID_PATH;
17
+ }
18
+
19
+ out_list->entries = NULL;
20
+ out_list->count = 0;
21
+
22
+ DIR* dir = opendir(path);
23
+ if (!dir) {
24
+ return map_posix_errno(errno);
25
+ }
26
+
27
+ size_t capacity = 16;
28
+ out_list->entries = (DirEntry*)malloc(capacity * sizeof(DirEntry));
29
+ if (!out_list->entries) {
30
+ closedir(dir);
31
+ return ERR_IO;
32
+ }
33
+
34
+ struct dirent* entry;
35
+ while ((entry = readdir(dir)) != NULL) {
36
+ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
37
+ continue;
38
+ }
39
+
40
+ if (out_list->count >= capacity) {
41
+ capacity *= 2;
42
+ DirEntry* resized = (DirEntry*)realloc(out_list->entries, capacity * sizeof(DirEntry));
43
+ if (!resized) {
44
+ closedir(dir);
45
+ free_dir_list(out_list);
46
+ return ERR_IO;
47
+ }
48
+ out_list->entries = resized;
49
+ }
50
+
51
+ bool is_dir = false;
52
+ #ifdef _DIRENT_HAVE_D_TYPE
53
+ if (entry->d_type != DT_UNKNOWN) {
54
+ is_dir = (entry->d_type == DT_DIR);
55
+ } else
56
+ #endif
57
+ {
58
+ struct stat st;
59
+ if (fstatat(dirfd(dir), entry->d_name, &st, 0) == 0) {
60
+ is_dir = S_ISDIR(st.st_mode);
61
+ }
62
+ }
63
+
64
+ out_list->entries[out_list->count].name = strdup(entry->d_name);
65
+ out_list->entries[out_list->count].is_dir = is_dir;
66
+ out_list->count++;
67
+ }
68
+
69
+ closedir(dir);
70
+ return SUCCESS;
71
+ }
@@ -0,0 +1,16 @@
1
+ // c_src/diskops/shared/dir_types.c
2
+
3
+ #include <stdlib.h>
4
+ #include "dir_types.h"
5
+
6
+ void free_dir_list(DirList* list) {
7
+ if (!list) return;
8
+ if (list->entries) {
9
+ for (size_t i = 0; i < list ->count; ++i) {
10
+ free(list->entries[i].name);
11
+ }
12
+ free(list->entries);
13
+ list->entries = NULL;
14
+ }
15
+ list->count = 0;
16
+ }
@@ -0,0 +1,21 @@
1
+ // c_src/diskops/shared/dir_types.h
2
+
3
+ #ifndef DIR_TYPES_H
4
+ #define DIR_TYPES_H
5
+
6
+ #include <stdbool.h>
7
+ #include <stddef.h>
8
+
9
+ typedef struct {
10
+ char* name;
11
+ bool is_dir;
12
+ } DirEntry;
13
+
14
+ typedef struct {
15
+ DirEntry* entries;
16
+ size_t count;
17
+ } DirList;
18
+
19
+ void free_dir_list(DirList* list);
20
+
21
+ #endif /* DIR_TYPES_H */
@@ -0,0 +1,65 @@
1
+ // c_src/diskops/win32/dir.c
2
+
3
+ #include <windows.h>
4
+ #include <stdio.h>
5
+ #include <stdlib.h>
6
+ #include <string.h>
7
+ #include "../shared/native_errors.h"
8
+ #include "../shared/dir_types.h"
9
+
10
+ Result list_dir(const char* path, DirList* out_list) {
11
+ if (!path || path[0] == '\0' || !out_list) {
12
+ return ERR_INVALID_PATH;
13
+ }
14
+
15
+ out_list->entries = NULL;
16
+ out_list->count = 0;
17
+
18
+ char search_pattern[MAX_PATH];
19
+ snprintf(search_pattern, sizeof(search_pattern), "%s\\*", path);
20
+
21
+ WIN32_FIND_DATAA find_data;
22
+ HANDLE h_find = FindFirstFileA(search_pattern, &find_data);
23
+ if (h_find == INVALID_HANDLE_VALUE) {
24
+ return map_win32_error(GetLastError());
25
+ }
26
+
27
+ size_t capacity = 16;
28
+ out_list->entries = (DirEntry*)malloc(capacity * sizeof(DirEntry));
29
+ if (!out_list->entries) {
30
+ FindClose(h_find);
31
+ return ERR_IO;
32
+ }
33
+
34
+ do {
35
+ if (strcmp(find_data.cFileName, ".") == 0 || strcmp(find_data.cFileName, "..") == 0) {
36
+ continue;
37
+ }
38
+
39
+ if (out_list->count >= capacity) {
40
+ capacity *= 2;
41
+ DirEntry* resized = (DirEntry*)realloc(out_list->entries, capacity * sizeof(DirEntry));
42
+ if (!resized) {
43
+ FindClose(h_find);
44
+ free_dir_list(out_list);
45
+ return ERR_IO;
46
+ }
47
+ out_list->entries = resized;
48
+ }
49
+
50
+ bool is_dir = (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
51
+ out_list->entries[out_list->count].name = _strdup(find_data.cFileName);
52
+ out_list->entries[out_list->count].is_dir = is_dir;
53
+ out_list->count++;
54
+ } while (FindNextFileA(h_find, &find_data) != 0);
55
+
56
+ DWORD err = GetLastError();
57
+ FindClose(h_find);
58
+
59
+ if (err != ERROR_NO_MORE_FILES && err != ERROR_SUCCESS) {
60
+ free_dir_list(out_list);
61
+ return map_win32_error(err);
62
+ }
63
+
64
+ return SUCCESS;
65
+ }
@@ -5,13 +5,16 @@ import sys
5
5
 
6
6
  sources = [
7
7
  "c_src/diskops/diskops.c",
8
+ "c_src/diskops/shared/dir_types.c",
8
9
  ]
9
10
 
10
11
  if sys.platform == "win32":
11
12
  sources.append("c_src/diskops/win32/cat.c")
13
+ sources.append("c_src/diskops/win32/dir.c")
12
14
  sources.append("c_src/diskops/win32/touch.c")
13
15
  else:
14
16
  sources.append("c_src/diskops/posix/cat.c")
17
+ sources.append("c_src/diskops/posix/dir.c")
15
18
  sources.append("c_src/diskops/posix/touch.c")
16
19
 
17
20
  native_diskops = Extension(
@@ -71,29 +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 Dir(BaseCmd):
75
- name = "dir"
76
- description = "List all files in the current working directory"
77
- min_args = 0
78
- options = None
79
- aliases = ["ls"]
80
-
81
- def execute(self, args):
82
- try:
83
- current_path = os.getcwd()
84
- items = os.listdir(current_path)
85
- lines = [f"\nDirectory: '{current_path}'"]
86
- for item in items:
87
- if os.path.isdir(os.path.join(current_path, item)):
88
- lines.append(f"[DIR] {item}/")
89
- else:
90
- lines.append(f"[FILE] {item}")
91
- lines.append(f"\nTotal items in directory: {len(items)}\n")
92
- return (0, "\n".join(lines))
93
- except Exception as e:
94
- return (1, f"\nSystem Error: Unable to list directory ({e})\n")
95
-
96
-
97
74
  class MkDir(BaseCmd):
98
75
  name = "mkdir"
99
76
  description = "Create a new directory from the current working directory"
@@ -5,8 +5,8 @@ import os
5
5
  import platform
6
6
  import time
7
7
 
8
- BUILD = 149
9
- VERSION = "1.3.9"
8
+ BUILD = 151
9
+ VERSION = "1.3.11"
10
10
 
11
11
 
12
12
  def _resolve_app_dir() -> Path:
@@ -59,7 +59,7 @@ INSTALLED_COMMANDS: list[BaseCmd] = [
59
59
  Cmds(),
60
60
  utils.Clear(),
61
61
  diskops_legacy.Copy(),
62
- diskops_legacy.Dir(),
62
+ diskops.Dir(),
63
63
  utils.Echo(),
64
64
  fs.Fs(),
65
65
  utils.History(),
@@ -1,10 +1,12 @@
1
1
  # src/flyshell/native/diskops_handler.py
2
2
 
3
- from pathlib import Path
4
3
  from flyshell.abstract.base_cmd import BaseCmd
5
4
  from flyshell.native import diskops_bridge as bridge
6
5
  from flyshell.native.legacy import diskops as legacy
7
6
 
7
+ from pathlib import Path
8
+ import os
9
+
8
10
 
9
11
  class Cat(BaseCmd):
10
12
  name = "cat"
@@ -62,6 +64,32 @@ class Cat(BaseCmd):
62
64
  return (0, "\n".join(output_lines))
63
65
 
64
66
 
67
+ class Dir(BaseCmd):
68
+ name = "dir"
69
+ description = "List all files in the current working directory"
70
+ min_args = 0
71
+ options = None
72
+ aliases = ["ls"]
73
+
74
+ def execute(self, args):
75
+ target_str = args[0].strip("\"'") if args else os.getcwd()
76
+ target_path = Path(target_str).expanduser().resolve()
77
+ if bridge.has_native_support() and hasattr(bridge._native, "dir"):
78
+ code, items = bridge._native.dir(str(target_path))
79
+ else:
80
+ code, items = legacy.lgc_dir(target_path)
81
+ if code != 0:
82
+ return bridge.translate_error(code, str(target_path))
83
+ lines = [f"\nDirectory: '{target_path}'"]
84
+ for name, is_dir in items:
85
+ if is_dir:
86
+ lines.append(f"[DIR] {name}/")
87
+ else:
88
+ lines.append(f"[FILE] {name}")
89
+ lines.append(f"\nTotal items in directory: {len(items)}\n")
90
+ return (0, "\n".join(lines))
91
+
92
+
65
93
  class Touch(BaseCmd):
66
94
  name = "touch"
67
95
  description = "Create an empty file or update existing file timestamps"
@@ -1,6 +1,7 @@
1
1
  # src/flyshell/native/legacy/diskops.py
2
2
 
3
3
  from pathlib import Path
4
+ import os
4
5
 
5
6
 
6
7
  def lgc_cat(target_path: Path) -> tuple[int, str]:
@@ -22,6 +23,30 @@ def lgc_cat(target_path: Path) -> tuple[int, str]:
22
23
  return (-13, "") # ERR_IO
23
24
 
24
25
 
26
+ def lgc_dir(target_path: Path) -> tuple[int, list[tuple[str, bool]]]:
27
+ if not target_path.exists():
28
+ return (-1, []) # ERR_NOT_FOUND
29
+ if not target_path.is_dir():
30
+ return (-4, []) # ERR_NOT_DIR
31
+ try:
32
+ entries: list[tuple[str, bool]] = []
33
+ with os.scandir(target_path) as it:
34
+ for entry in it:
35
+ try:
36
+ entries.append((entry.name, entry.is_dir()))
37
+ except OSError:
38
+ entries.append((entry.name, False))
39
+ return (0, entries) # SUCCESS
40
+ except PermissionError:
41
+ return (-2, []) # ERR_PERMISSION
42
+ except OSError as e:
43
+ if getattr(e, "errno", None) == 20:
44
+ return (-4, []) # ERR_NOT_DIR
45
+ return (-13, []) # ERR_IO
46
+ except Exception:
47
+ return (-99, []) # ERR_UNKNOWN
48
+
49
+
25
50
  def lgc_touch(target_path: Path) -> tuple[int, str]:
26
51
  if target_path.is_dir():
27
52
  return (-3, "") # ERR_IS_DIR
@@ -33,8 +58,8 @@ def lgc_touch(target_path: Path) -> tuple[int, str]:
33
58
  except FileNotFoundError:
34
59
  return (-1, "") # ERR_NOT_FOUND
35
60
  except OSError as e:
36
- if getattr(e, "errno", None) == 28: # ENOSPC
37
- return (-12, "")
61
+ if getattr(e, "errno", None) == 28:
62
+ return (-12, "") # ERR_NO_SPACE
38
63
  return (-13, "") # ERR_IO
39
64
  except Exception:
40
65
  return (-99, "") # ERR_UNKNOWN
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flyshell
3
- Version: 1.3.9
3
+ Version: 1.3.11
4
4
  Summary: A modular, zero-dependency command-line environment in Python.
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.10
@@ -5,9 +5,13 @@ pyproject.toml
5
5
  setup.py
6
6
  c_src/diskops/diskops.c
7
7
  c_src/diskops/posix/cat.c
8
+ c_src/diskops/posix/dir.c
8
9
  c_src/diskops/posix/touch.c
10
+ c_src/diskops/shared/dir_types.c
11
+ c_src/diskops/shared/dir_types.h
9
12
  c_src/diskops/shared/native_errors.h
10
13
  c_src/diskops/win32/cat.c
14
+ c_src/diskops/win32/dir.c
11
15
  c_src/diskops/win32/touch.c
12
16
  src/flyshell/__init__.py
13
17
  src/flyshell/constants.py
@@ -48,7 +52,7 @@ tests/test_auth.py
48
52
  tests/test_data.py
49
53
  tests/test_deps.py
50
54
  tests/test_directory.py
51
- tests/test_diskops.py
55
+ tests/test_diskops_old.py
52
56
  tests/test_env.py
53
57
  tests/test_fs.py
54
58
  tests/test_loader.py
@@ -1,57 +1,6 @@
1
- # tests/test_diskops.py
1
+ # tests/test_diskops_old.py
2
2
 
3
3
  from flyshell.builtin import diskops
4
- import flyshell
5
-
6
- import pytest
7
-
8
- pytestmark = pytest.mark.skip(reason="Refactoring diskops to modular native C backend")
9
-
10
-
11
- def test_touch_creates_file_and_updates_timestamp(tmp_path):
12
- cmd = diskops.Touch()
13
- target = tmp_path / "test.txt"
14
- code, msg = cmd.execute([str(target)])
15
- assert code == 0
16
- assert "Created file" in msg
17
- assert target.exists()
18
- code, msg = cmd.execute([str(target)])
19
- assert code == 0
20
- assert "Updated timestamp" in msg
21
-
22
-
23
- def test_touch_missing_parent_directory(tmp_path):
24
- cmd = diskops.Touch()
25
- target = tmp_path / "nonexistent_dir" / "test.txt"
26
- code, msg = cmd.execute([str(target)])
27
- assert code == 1
28
- assert "Parent directory does not exist" in msg
29
-
30
-
31
- def test_cat_reads_content_with_limit_and_numbers(tmp_path):
32
- file_path = tmp_path / "sample.txt"
33
- file_path.write_text("line 1\nline 2\nline 3\nline 4\n")
34
- cmd = diskops.Cat()
35
- code, msg = cmd.execute([str(file_path)])
36
- assert code == 0
37
- assert "line 1" in msg and "line 4" in msg
38
- code, msg = cmd.execute(["-n", "-l", "2", str(file_path)])
39
- assert code == 0
40
- assert "1 | line 1" in msg
41
- assert "2 | line 2" in msg
42
- assert "line 3" not in msg
43
-
44
-
45
- def test_cat_nonexistent_and_empty_file(tmp_path):
46
- cmd = diskops.Cat()
47
- code, msg = cmd.execute([str(tmp_path / "missing.txt")])
48
- assert code == 1
49
- assert "not found" in msg
50
- empty_file = tmp_path / "empty.txt"
51
- empty_file.write_text("")
52
- code, msg = cmd.execute([str(empty_file)])
53
- assert code == 1
54
- assert "is empty" in msg
55
4
 
56
5
 
57
6
  def test_mkdir_standard_and_parents(tmp_path):
@@ -124,7 +73,3 @@ def test_rmdir_empty_and_non_empty(tmp_path):
124
73
  code, msg = cmd.execute(["-f", str(target_dir)])
125
74
  assert code == 0
126
75
  assert not target_dir.exists()
127
-
128
-
129
- def test_native_disk_c_ext():
130
- assert flyshell.check_native() is True
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