Metadata-Version: 2.4
Name: nimshell
Version: 0.5.5
Summary: A nimble shell tool that uses Python syntax to replace traditional commands.
Author-email: Pophu <pophu@126.com>
License: MIT
Project-URL: Homepage, https://github.com/pophu/nimshell
Project-URL: Repository, https://github.com/pophu/nimshell.git
Project-URL: Issues, https://github.com/pophu/nimshell/issues
Keywords: nimshell
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# nimshell

Nimshell is a convenient shell tool that uses Python syntax to replace traditional commands. It serves as an alternative to the Linux shell, Windows PowerShell, and Windows Batch.

## Installation

```bash
pip install nimshell
```

## Usage

```bash
nimshell
nimshell -f NimShell.py
```

## Features

Cross-Platform: Supports Windows, Linux, and macOS, with automatic adaptation to system encoding and path separators.
Strategy Pattern for Subprocess Interaction: Features dual modes for Auto-Reply (AutoInteractive) and Manual Interaction (TerminalInteractive), with support for runtime fallback switching.
Asynchronous & Non-Blocking: An intelligent subprocess manager built on asyncio that reads stdout in real time and injects into stdin without blocking the main event loop.
A quick translation tip:
"runtime fallback switching". In software engineering, "fallback" is the most standard and professional term for gracefully degrading or switching to a backup mode when the primary method isn't working or needs to be changed.

## Example

```python
from nimshell.Helper import Helper
from nimshell.MyCommands import Commands, PromptInput, StdIn
from nimshell.shell import SshShell

hlp = Helper()

data = hlp.dataset("git")
print("========================")
# print(data["ChainCommand"])


params = []
params.append(StdIn(seq=0, key="name", value="jim").todict())
params.append(StdIn(seq=0, key="age", value="48").todict())
hlp.Append(PARAMS=params)

# prompts = []
# params.update({"username": "admin", "password": "s3cret"})
# hlp.Replace(PARAMS=params)

prompts = []
prompts.append(PromptInput(seq=0, prompt="username", input="admin").todict())
prompts.append(PromptInput(seq=0, prompt="password", input="s3cret").todict())
hlp.Append(PROMPTS=prompts)


hlp.Refresh()

print(hlp["PARAMS"])
print(hlp["PROMPTS"])

ssh = SshShell()
d = ssh.debug()
# print(d)

demo = Commands("demo", r"D:/MyCodeNew/nimshell/demo.exe")
# demo.stdout(lineno=1, sep=" ", pos=0, key="demo")
hlp.Command(demo.name, demo)
# hlp.Command(**demo.todict())

info = hlp.Alias("info", demo.name)

print("=============")
print(demo.todict())


```

## Development

```bash
# Clone the repo
git clone https://github.com/pophu/nimshell.git
cd nimshell


# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Lint
ruff check src/ tests/

# Type check
mypy src/

# Build
python -m build
```
