xmyshell 0.1.2__tar.gz → 0.1.4__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.
- {xmyshell-0.1.2/xmyshell.egg-info → xmyshell-0.1.4}/PKG-INFO +10 -1
- {xmyshell-0.1.2 → xmyshell-0.1.4}/README.md +9 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/pyproject.toml +1 -1
- xmyshell-0.1.4/xmyshell/__main__.py +20 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell/kernel.py +32 -2
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell/meta.py +13 -12
- xmyshell-0.1.4/xmyshell/update.py +29 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4/xmyshell.egg-info}/PKG-INFO +10 -1
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell.egg-info/SOURCES.txt +1 -0
- xmyshell-0.1.2/xmyshell/__main__.py +0 -12
- {xmyshell-0.1.2 → xmyshell-0.1.4}/LICENSE +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/setup.cfg +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell/__init__.py +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell/completer.py +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell/data/commands.json +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell/environment.py +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell/init.py +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell/keybindings.py +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell/lexer.py +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell/main.py +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell/themes.py +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell/utils.py +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell.egg-info/dependency_links.txt +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell.egg-info/entry_points.txt +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell.egg-info/requires.txt +0 -0
- {xmyshell-0.1.2 → xmyshell-0.1.4}/xmyshell.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xmyshell
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: XmyShell is a shell-like tool built on top of prompt_toolkit which provides a persistent Python runtime.
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -103,6 +103,15 @@ foobar
|
|
|
103
103
|
❯ reload
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
+
- Update xmyshell (optionally to a specific version).
|
|
107
|
+
```
|
|
108
|
+
❯ udpate
|
|
109
|
+
```
|
|
110
|
+
or
|
|
111
|
+
```
|
|
112
|
+
❯ update 0.1.3
|
|
113
|
+
```
|
|
114
|
+
|
|
106
115
|
- Syntax highlighting via `prompt_toolkit`
|
|
107
116
|
- Powerful auto-completion, history search, and automatic bracket/quote pairing
|
|
108
117
|
- Startup configuration: `~/.xmyshell/config.py` loaded at launch
|
|
@@ -93,6 +93,15 @@ foobar
|
|
|
93
93
|
❯ reload
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
+
- Update xmyshell (optionally to a specific version).
|
|
97
|
+
```
|
|
98
|
+
❯ udpate
|
|
99
|
+
```
|
|
100
|
+
or
|
|
101
|
+
```
|
|
102
|
+
❯ update 0.1.3
|
|
103
|
+
```
|
|
104
|
+
|
|
96
105
|
- Syntax highlighting via `prompt_toolkit`
|
|
97
106
|
- Powerful auto-completion, history search, and automatic bracket/quote pairing
|
|
98
107
|
- Startup configuration: `~/.xmyshell/config.py` loaded at launch
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def main() -> None:
|
|
6
|
+
argv = sys.argv
|
|
7
|
+
|
|
8
|
+
if len(argv) == 1:
|
|
9
|
+
from .main import xmyshell_main
|
|
10
|
+
xmyshell_main()
|
|
11
|
+
elif argv[1] == "--update":
|
|
12
|
+
subprocess.run([sys.executable, "-m", "xmyshell.update"] + argv[2:])
|
|
13
|
+
elif argv[1] == "--version":
|
|
14
|
+
from .meta import WELCOME_MESSAGE
|
|
15
|
+
print(WELCOME_MESSAGE)
|
|
16
|
+
elif argv[1] == "--help":
|
|
17
|
+
from .meta import HELP_MESSAGE
|
|
18
|
+
print(HELP_MESSAGE)
|
|
19
|
+
else:
|
|
20
|
+
print(f"Error: cannot parse arguments '{' '.join(argv[1:])}'")
|
|
@@ -13,7 +13,11 @@ def _reload() -> None:
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
def xmyshell_source(path: str) -> None:
|
|
16
|
-
_updated = runpy.run_path(
|
|
16
|
+
_updated = runpy.run_path(
|
|
17
|
+
path_name=os.path.expanduser(path),
|
|
18
|
+
init_globals=namespace,
|
|
19
|
+
run_name="__main__",
|
|
20
|
+
)
|
|
17
21
|
namespace.clear()
|
|
18
22
|
namespace.update(_updated)
|
|
19
23
|
|
|
@@ -82,7 +86,7 @@ def xmyshell_raw_command(cmd_line: str) -> int | None:
|
|
|
82
86
|
command = args[0]
|
|
83
87
|
match command:
|
|
84
88
|
case "pyexec":
|
|
85
|
-
code = cmd_line[len(command):].strip()
|
|
89
|
+
code = cmd_line[len(command) :].strip()
|
|
86
90
|
if not code:
|
|
87
91
|
pyerror("pyexec: missing code")
|
|
88
92
|
return -1
|
|
@@ -92,6 +96,7 @@ def xmyshell_raw_command(cmd_line: str) -> int | None:
|
|
|
92
96
|
return 0
|
|
93
97
|
except Exception as e:
|
|
94
98
|
import traceback
|
|
99
|
+
|
|
95
100
|
namespace["last_error"] = e
|
|
96
101
|
namespace["last_traceback"] = traceback.format_exc()
|
|
97
102
|
pyerror(f"{type(e).__name__}: {e}")
|
|
@@ -128,6 +133,13 @@ def xmyshell_raw_command(cmd_line: str) -> int | None:
|
|
|
128
133
|
_reload()
|
|
129
134
|
return 0
|
|
130
135
|
|
|
136
|
+
case "update":
|
|
137
|
+
from .update import xmyshell_update
|
|
138
|
+
subprocess.run(
|
|
139
|
+
[sys.executable, "-m", "xmyshell.update"]
|
|
140
|
+
+ (args[1:] if len(args) > 1 else [])
|
|
141
|
+
)
|
|
142
|
+
|
|
131
143
|
if command.startswith("import") or command.startswith("from"):
|
|
132
144
|
try:
|
|
133
145
|
exec(cmd_line, dict(os.environ), namespace)
|
|
@@ -136,6 +148,22 @@ def xmyshell_raw_command(cmd_line: str) -> int | None:
|
|
|
136
148
|
pyerror(f"{type(e).__name__}: {e}")
|
|
137
149
|
return -1
|
|
138
150
|
|
|
151
|
+
def _fix_first_word(cmd_line: str) -> str:
|
|
152
|
+
# strip is unnecessary
|
|
153
|
+
if cmd_line.startswith('"'):
|
|
154
|
+
end = cmd_line.find('"', 1)
|
|
155
|
+
if end == -1:
|
|
156
|
+
return cmd_line
|
|
157
|
+
first = cmd_line[:end + 1]
|
|
158
|
+
rest = cmd_line[end + 1:]
|
|
159
|
+
else:
|
|
160
|
+
parts = cmd_line.split(None, 1)
|
|
161
|
+
first = parts[0]
|
|
162
|
+
rest = (" " + parts[1]) if len(parts) > 1 else ""
|
|
163
|
+
|
|
164
|
+
fixed = first.replace("/", "\\")
|
|
165
|
+
return fixed + rest
|
|
166
|
+
|
|
139
167
|
|
|
140
168
|
def xmyshell(cmd_line: str) -> int:
|
|
141
169
|
cmd_line = cmd_line.strip()
|
|
@@ -250,6 +278,8 @@ def xmyshell(cmd_line: str) -> int:
|
|
|
250
278
|
case "exit":
|
|
251
279
|
sys.exit(0)
|
|
252
280
|
|
|
281
|
+
if os.name == "nt":
|
|
282
|
+
cmd_line = _fix_first_word(cmd_line)
|
|
253
283
|
if target_var:
|
|
254
284
|
result = subprocess.run(
|
|
255
285
|
cmd_line, shell=True, env=os.environ, capture_output=True, text=True
|
|
@@ -17,18 +17,19 @@ HELP_MESSAGE = f"""\033[1;36m
|
|
|
17
17
|
{WELCOME_MESSAGE}
|
|
18
18
|
|
|
19
19
|
Built-in Commands:
|
|
20
|
-
help
|
|
21
|
-
print <expr>
|
|
22
|
-
pyexec <stmt>
|
|
23
|
-
source <file.py>
|
|
24
|
-
export NAME
|
|
25
|
-
import <module> [as <alt>]
|
|
26
|
-
from <module> import
|
|
27
|
-
reload
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
help Show help documents.
|
|
21
|
+
print <expr> Evaluate and print a Python expression.
|
|
22
|
+
pyexec <stmt> Execute a Python statement (e.g. pyexec x = 1).
|
|
23
|
+
source <file.py> Run a Python script in the current namespace.
|
|
24
|
+
export <NAME>=<value> Set an environment variable (supports {{expr}}).
|
|
25
|
+
import <module> [as <alt>] Import a Python module.
|
|
26
|
+
from <module> import <names> Import names from a module.
|
|
27
|
+
reload Reload environment (e.g. exit virtualenv).
|
|
28
|
+
update [<version>] Update xmyshell (optionally to a specific version).
|
|
29
|
+
cd <dir> Change directory (supports {{expr}}).
|
|
30
|
+
pwd Print working directory.
|
|
31
|
+
clear Clear the terminal screen.
|
|
32
|
+
exit Exit XmyShell.
|
|
32
33
|
|
|
33
34
|
Inline Python:
|
|
34
35
|
Use {{expression}} anywhere in a command to expand its result.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import time
|
|
4
|
+
import subprocess
|
|
5
|
+
|
|
6
|
+
def xmyshell_update(version: str | None = None) -> None:
|
|
7
|
+
if os.name == "nt":
|
|
8
|
+
subprocess.run("taskkill /F /IM xmyshell.exe", shell=True)
|
|
9
|
+
else:
|
|
10
|
+
subprocess.run(["pkill", "-f", "-x", "xmyshell"])
|
|
11
|
+
|
|
12
|
+
time.sleep(1)
|
|
13
|
+
|
|
14
|
+
install_args = [
|
|
15
|
+
sys.executable,
|
|
16
|
+
"-m",
|
|
17
|
+
"pip",
|
|
18
|
+
"install",
|
|
19
|
+
"--upgrade",
|
|
20
|
+
"xmyshell" + (f"=={version}" if version else ""),
|
|
21
|
+
]
|
|
22
|
+
print()
|
|
23
|
+
returncode = subprocess.run(install_args).returncode
|
|
24
|
+
print("Press <Enter> to continue ...", end="")
|
|
25
|
+
sys.exit(returncode)
|
|
26
|
+
|
|
27
|
+
if __name__ == "__main__":
|
|
28
|
+
version = sys.argv[1] if len(sys.argv) >= 2 else None
|
|
29
|
+
xmyshell_update(version)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xmyshell
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: XmyShell is a shell-like tool built on top of prompt_toolkit which provides a persistent Python runtime.
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -103,6 +103,15 @@ foobar
|
|
|
103
103
|
❯ reload
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
+
- Update xmyshell (optionally to a specific version).
|
|
107
|
+
```
|
|
108
|
+
❯ udpate
|
|
109
|
+
```
|
|
110
|
+
or
|
|
111
|
+
```
|
|
112
|
+
❯ update 0.1.3
|
|
113
|
+
```
|
|
114
|
+
|
|
106
115
|
- Syntax highlighting via `prompt_toolkit`
|
|
107
116
|
- Powerful auto-completion, history search, and automatic bracket/quote pairing
|
|
108
117
|
- Startup configuration: `~/.xmyshell/config.py` loaded at launch
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
|
|
3
|
-
def main() -> None:
|
|
4
|
-
if "--version" in sys.argv:
|
|
5
|
-
from .meta import WELCOME_MESSAGE
|
|
6
|
-
print(WELCOME_MESSAGE)
|
|
7
|
-
elif "--help" in sys.argv:
|
|
8
|
-
from .meta import HELP_MESSAGE
|
|
9
|
-
print(HELP_MESSAGE)
|
|
10
|
-
else:
|
|
11
|
-
from .main import xmyshell_main
|
|
12
|
-
xmyshell_main()
|
|
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
|