Skip to main content

CLI LLM Man

CLI LLM Man is a command-line interface tool designed to generate summaries, examples, and custom commands based on user intent using man pages and large language models (LLMs). This tool aims to simplify the process of retrieving and understanding command-line documentation.

Features

  • Generate concise summaries of man pages
  • Display practical usage examples for specific commands
  • Create custom commands based on natural language descriptions
  • Interactive mode for continuous querying
  • Support for multiple LLM providers (OpenAI and Anthropic)
  • Response caching to reduce API calls and improve speed

Installation

To install the CLI LLM Man tool, you can either clone the repository or install it via pip.

Option 1: Install via pip

python3 -m venv ~/venvs/cli-llm-man
source ~/venvs/cli-llm-man/bin/activate
pip install -e .

Option 2: Clone the repository

git clone https://github.com/sajid-karim/cli-llm-man.git
cd cli-llm-man
pip install -r requirements.txt

Configuration

Before using the tool, you need to configure your LLM API key. You can do this in two ways:

Option 1: Environment Variable

Set one of the following environment variables:

For OpenAI (preferred)

export OPENAI_API_KEY='your-key-here'

For Anthropic

export ANTH_API_KEY='your-key-here'

Option 2: Configuration File

Create a configuration file at ~/.cli_llm_man/config.yaml with the following content:

# For OpenAI
LLM_API_KEY: your_openai_key_here
PROVIDER: openai  # Optional, defaults to openai
MODEL: gpt-4o    # Optional, defaults to gpt-4o

# OR for Anthropic
LLM_API_KEY: your_anthropic_key_here
PROVIDER: anthropic
MODEL: claude-3-opus-20240229  # Optional

You can find a sample configuration file in config.example.yaml.

Usage

Once installed and configured, you can use the CLI LLM Man tool with the following commands:

Generate Summary

To generate a summary for a given command:

# Using the installed command
cli-llm-man summary ls

# OR using the module directly
python -m cli_llm_man.main summary ls

Show Usage Examples

To display usage examples for a specific command:

cli-llm-man example grep

# OR
python -m cli_llm_man.main example grep

Generate Command

To create a command based on your intent:

cli-llm-man generate "find all PDF files modified in the last 7 days"

# OR
python -m cli_llm_man.main generate "find all PDF files modified in the last 7 days"

Interactive Mode

For continuous interaction with the tool:

cli-llm-man interactive

# Then type commands like:
# summary ls
# example grep
# generate "count lines in all python files"
# exit

Alias Setup

To simplify running the CLI LLM Man tool, you can add a shortcut alias to your shell profile. This alias allows you to run the tool using the command llm-man instead of typing out cli-llm-man.

To set up the alias, run the following command in your terminal:

setup-llm-man-alias

This command will add the alias to your shell profile (e.g. .bashrc, .bash_profile, or .zshrc). After running the command, reload your shell (or source the profile) with:

source ~/.bashrc
# or
source ~/.bash_profile
# or for zsh users:
source ~/.zshrc

Now you can run the tool using the shorter command. For example:

llm-man summary ls
llm-man example grep
llm-man generate "find all PDF files modified in the last 7 days"

Caching

By default, responses are cached to improve performance and reduce API calls. The cache is stored in ~/.cli_llm_man/cache/. To disable caching, set use_cache: False in your config file.

Troubleshooting

If you encounter any issues, please ensure that:

  • Your API key is set correctly
  • The required packages are installed (openai for OpenAI, anthropic for Claude)
  • You have internet connectivity to reach the API endpoints
  • You have the necessary permissions to execute the man command on your system
  • Check the tests directory for unit tests to verify functionality.

Contributing

Contributions are welcome! Please read the CONTRIBUTING.md for guidelines on how to contribute to this project.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Metadata

Release files for cli-llm-man-sajid-karim 0.1.0

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

Source distribution (sdist)

Source distribution for cli-llm-man-sajid-karim 0.1.0
File Size Uploaded
cli_llm_man_sajid_karim-0.1.0.tar.gz 12.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cli-llm-man-sajid-karim 0.1.0
File Interpreter ABI Platform
cli_llm_man_sajid_karim-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.5 kB

Release files / cli_llm_man_sajid_karim-0.1.0.tar.gz

Download URL cli_llm_man_sajid_karim-0.1.0.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
22665d834dade2c5976437f7b690ddc55649514a634b2af51071c53a888dfa13
BLAKE2b-256 checksum
How to use checksums
149bf78cce43cc2aaf1e6aa2ba73bbf612e9c1c1ef3698a688749ad27137963d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / cli_llm_man_sajid_karim-0.1.0-py3-none-any.whl

Download URL cli_llm_man_sajid_karim-0.1.0-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6abc0b4c39157a28ef993eb364f9477b2a1d2fd0388150bb85092e3f48efb24d
BLAKE2b-256 checksum
How to use checksums
b5ab24ad88300795049ad99d72f8e7049ff63b843c7eda3dc9bbe55fbf48acc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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