Skip to main content

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

pip install nimshell

Usage

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

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

# 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

Metadata

Release files for nimshell 0.5.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for nimshell 0.5.3
File Interpreter ABI Platform
nimshell-0.5.3-py3-none-any.whl Python 3 none any Details

Release files / nimshell-0.5.3-py3-none-any.whl

Download URL nimshell-0.5.3-py3-none-any.whl
Size 80.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
928b88ca914f9d5091b4562c50ff982ca2f6e0ede3483cc4652b9b8a3beadc6c
BLAKE2b-256 checksum
How to use checksums
efcbb6a3c27de2e5d89e91047fc0dbaf9c9d78c2c0814bff4da186c4a0a434db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.6

Release history Release notifications | RSS feed

0.5.5

1 release file

This release

0.5.3 This release

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page