Skip to main content

Natural language to terminal command translation tool

Project description

nl2cmd

A natural language to terminal command translation tool that helps you convert plain English descriptions into appropriate terminal commands based on your operating system.

Features

  • Multi-platform support: Automatically detects and adapts to Linux, macOS, and Windows
  • Natural language processing: Understands common phrases and descriptions
  • Smart intent detection: Maps your description to the most appropriate command
  • Command explanations: Provides detailed breakdowns of generated commands
  • Alternative suggestions: Offers multiple approaches when available
  • CLI interface: Easy-to-use command-line tool

Installation

From PyPI (when published)

pip install nl2cmd

From source

git clone https://github.com/yourusername/nl2cmd.git
cd nl2cmd
pip install -e .

Usage

Command Line Interface

# Basic usage
nl2cmd "show current directory"
nl2cmd "list files in this folder"
nl2cmd "create a new directory called test"

# With options
nl2cmd --explain "remove all files in current directory"
nl2cmd --json "show running processes"
nl2cmd --os linux "list network connections"

Python API

from nl2cmd import NL2Cmd

# Initialize translator
translator = NL2Cmd()

# Translate natural language to command
result = translator.translate("show current directory")
print(f"Command: {result.command}")
print(f"Explanation: {result.explanation}")

# Override OS for testing
translator = NL2Cmd(forced_os="windows")
result = translator.translate("list files")
print(f"Windows command: {result.command}")

Supported Commands

The tool recognizes and translates various types of operations:

File Operations

  • List files and directories (ls, dir)
  • Change directories (cd)
  • Create directories (mkdir)
  • Remove files (rm, del)
  • Copy files (cp, copy)
  • Move/rename files (mv, move)

System Information

  • Current working directory (pwd, cd)
  • Process management (ps, tasklist)
  • Network information (netstat, ss)
  • Disk and memory usage (df, du)

Package Management

  • Install packages (apt, brew, winget)
  • Update packages (apt update, brew upgrade)

Git Operations

  • Status, pull, push, clone
  • Branch management
  • Commit history

Docker Operations

  • Container management
  • Image operations
  • Build and run commands

Examples

Natural Language Linux/macOS Windows Explanation
"show current directory" pwd cd Display current working directory
"list files" ls dir List contents of current directory
"create folder test" mkdir test mkdir test Create a new directory
"remove file.txt" rm file.txt del file.txt Delete a file
"copy source to dest" cp source dest copy source dest Copy files

Development

Setup Development Environment

git clone https://github.com/yourusername/nl2cmd.git
cd nl2cmd
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -e ".[dev]"

Run Tests

pytest

Code Formatting

black src/ tests/
flake8 src/ tests/
mypy src/

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Inspired by the need to make terminal commands more accessible
  • Built with modern Python packaging standards
  • Uses semantic matching for natural language understanding

Roadmap

  • Expand command coverage
  • Add interactive mode
  • Support for command chaining
  • Integration with shell history
  • Machine learning improvements
  • Plugin system for custom commands

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nl2cmd-1.0.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nl2cmd-1.0.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file nl2cmd-1.0.0.tar.gz.

File metadata

  • Download URL: nl2cmd-1.0.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for nl2cmd-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fbba77d52be4e508d43c534479bdcf8b8d8b6d53e9d6a36e78975a95d0ec1813
MD5 fbc24f8723fd9c908bf401502755ac09
BLAKE2b-256 ab207ef950afee70aa18398757efc1140bdb9e91ee82a159a40cf0c02f74bd42

See more details on using hashes here.

File details

Details for the file nl2cmd-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: nl2cmd-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for nl2cmd-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5feb171caa86f08713d0e8cda1e6c690f28f154c01ce236ac57529d3df1d7bc
MD5 c7b7660b710da741e1913e8202f1120b
BLAKE2b-256 cf015fc3b1cdd8c7be1ba93f9f97e462133f06734f9a72174a214874dad5714b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page