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.1.0.tar.gz (22.4 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.1.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for nl2cmd-1.1.0.tar.gz
Algorithm Hash digest
SHA256 77b0f70302230ffebac3f1397d56974318d600be71fef65252cfa9e91369d508
MD5 4b286ff3e5f242a4e7a3b506bc7a395f
BLAKE2b-256 0d962b822579b4ff5d702ab35cae4d4d14a2656b5f888825049e5b72eee82f42

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for nl2cmd-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc7fd8b57f3c9992e400bb7edb93aa1a6063c71ef493987adabf80e1b2cfccbe
MD5 5178511970c088fd2f0f75ae955b00b9
BLAKE2b-256 9c4813191831d5a9caff1570605341760527d550df69ca5278853fb574902ae3

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