CLI Reference

Complete command-line interface reference for DrGPT with all options, flags, and usage patterns.

Synopsis

drgpt [OPTIONS] [PROMPT]

Basic Usage

# Simple query
drgpt "Your question here"

# Use specific mode
drgpt --code "Generate code"
drgpt --shell "System command"
drgpt --interface
drgpt --editor

Positional Arguments

PROMPT

The question or request to send to the AI.

  • Type: String

  • Required: No (unless using standard mode)

  • Default: None

# Basic prompt
drgpt "Explain machine learning"

# Multi-word prompts (quotes recommended)
drgpt "How do I optimize database queries for large datasets?"

Mode Options

--code

Generate pure code without explanations.

  • Type: Flag (no arguments)

  • Default: False

# Generate Python function
drgpt --code "Create a function to sort a list"

# Generate with specific language
drgpt --code "Create a React component for user authentication"

--shell

Generate system administration commands with interactive execution.

  • Type: Flag (no arguments)

  • Default: False

# Generate system command
drgpt --shell "Find all Python files larger than 1MB"

# Package management
drgpt --shell "Install Docker on Ubuntu"

--interface

Start interactive AI chat mode.

  • Type: Flag (no arguments)

  • Default: False

# Start interactive session
drgpt --interface

--editor

Open vi text editor for prompt composition.

  • Type: Flag (no arguments)

  • Default: False

# Open editor for complex prompts
drgpt --editor

Provider Options

--provider PROVIDER

Specify AI provider to use.

  • Type: String

  • Choices: openai, anthropic, google

  • Default: From configuration or openai

# Use OpenAI
drgpt --provider openai "Your question"

# Use Anthropic
drgpt --provider anthropic "Your question"

# Use Google AI
drgpt --provider google "Your question"

--model MODEL

Specify AI model to use.

  • Type: String

  • Default: Provider-specific default

OpenAI Models: - gpt-4 - gpt-4o-mini (default) - gpt-3.5-turbo

Anthropic Models: - claude-3-opus-20240229 - claude-3-sonnet-20240229 (default) - claude-3-haiku-20240307

Google Models: - gemini-pro (default)

# Specific model
drgpt --provider openai --model gpt-4 "Complex reasoning task"

# Cost-effective model
drgpt --provider openai --model gpt-4o-mini "Simple question"

--list-providers

List all available providers and models.

  • Type: Flag (no arguments)

# Show all providers and models
drgpt --list-providers

--api-key API_KEY

Set API key for the current provider.

  • Type: String

  • Security: Key is stored securely in configuration

# Set OpenAI key
drgpt --provider openai --api-key "sk-your-key-here"

# Set Anthropic key
drgpt --provider anthropic --api-key "sk-ant-your-key-here"

Output Options

--output FILE

Save response to file.

  • Type: String (file path)

  • Default: None (output to terminal)

# Save to file
drgpt --output response.md "Explain Docker architecture"

# Save with specific format
drgpt --code --output code.py "Create a web scraper"

--no-streaming

Disable real-time response streaming.

  • Type: Flag (no arguments)

  • Default: False (streaming enabled)

# Get complete response at once
drgpt --no-streaming "Explain quantum computing"

--no-markdown

Disable markdown formatting in output.

  • Type: Flag (no arguments)

  • Default: False (markdown enabled)

# Plain text output
drgpt --no-markdown "Simple explanation"

# Useful for scripts
RESPONSE=$(drgpt --no-markdown "Brief answer")

Configuration Options

--status

Show current configuration and provider status.

  • Type: Flag (no arguments)

# Show current settings
drgpt --status

--set-default

Set current provider and model as default.

  • Type: Flag (no arguments)

  • Requires: --provider and optionally --model

# Set OpenAI as default
drgpt --provider openai --model gpt-4 --set-default

Advanced Options

--temperature TEMP

Control response creativity and randomness.

  • Type: Float

  • Range: 0.0 to 1.0

  • Default: 0.7

# More focused responses
drgpt --temperature 0.1 "Factual explanation"

# More creative responses
drgpt --temperature 0.9 "Creative writing task"

--max-tokens TOKENS

Maximum number of tokens in response.

  • Type: Integer

  • Default: Provider-specific default

# Shorter responses
drgpt --max-tokens 500 "Brief summary"

# Longer responses
drgpt --max-tokens 2000 "Detailed analysis"

--timeout SECONDS

Request timeout in seconds.

  • Type: Integer

  • Default: 30

# Longer timeout for complex requests
drgpt --timeout 60 "Complex analysis task"

Debug and Information Options

--debug

Enable debug mode with detailed logging.

  • Type: Flag (no arguments)

  • Default: False

# Show debug information
drgpt --debug "Your question"

--verbose

Enable verbose output.

  • Type: Flag (no arguments)

  • Default: False

# Verbose logging
drgpt --verbose "Your question"

--version

Show DrGPT version information.

  • Type: Flag (no arguments)

# Show version
drgpt --version

--help

Show help message and usage information.

  • Type: Flag (no arguments)

# Show help
drgpt --help

Configuration File Options

--config CONFIG_FILE

Use specific configuration file.

  • Type: String (file path)

  • Default: ~/.config/drgpt/config

# Use custom config
drgpt --config ~/my-drgpt-config "Your question"

--no-config

Ignore configuration file and use defaults.

  • Type: Flag (no arguments)

# Use only command-line options
drgpt --no-config --provider openai "Your question"

Environment Variables

DrGPT respects these environment variables:

API Keys

OPENAI_API_KEY        # OpenAI API key
ANTHROPIC_API_KEY     # Anthropic API key
GOOGLE_API_KEY        # Google AI API key

Default Settings

DRGPT_DEFAULT_PROVIDER    # Default provider
DRGPT_DEFAULT_MODEL       # Default model
DRGPT_NO_STREAMING        # Disable streaming (true/false)
DRGPT_NO_MARKDOWN         # Disable markdown (true/false)

Advanced Settings

DRGPT_CONFIG_DIR          # Configuration directory
DRGPT_TIMEOUT             # Default timeout
DRGPT_MAX_TOKENS          # Default max tokens
DRGPT_TEMPERATURE         # Default temperature

Exit Codes

DrGPT uses these exit codes:

0    # Success
1    # General error
2    # Configuration error
3    # Network error
4    # API error
5    # User interruption (Ctrl+C)

Usage Examples

Basic Queries

# Simple question
drgpt "What is Docker?"

# Complex question with context
drgpt "How do I implement JWT authentication in a Node.js API with proper security practices?"

Provider and Model Selection

# Use specific provider
drgpt --provider anthropic "Analyze this philosophical argument"

# Use specific model for complex task
drgpt --provider openai --model gpt-4 "Design a distributed system architecture"

# Cost-effective model for simple tasks
drgpt --provider openai --model gpt-4o-mini "Explain basic concepts"

Mode-Specific Examples

# Code generation
drgpt --code "Create a Python class for handling HTTP requests"

# System administration
drgpt --shell "Set up SSL certificate for nginx"

# Complex prompt composition
drgpt --editor

# Interactive session
drgpt --interface

Output Control

# Save to file
drgpt --output analysis.md "Analyze current AI trends"

# Plain text for scripting
RESULT=$(drgpt --no-markdown "Brief answer")

# Immediate formatted output
drgpt --no-streaming "Detailed explanation"

Configuration Management

# Check current settings
drgpt --status

# Set new defaults
drgpt --provider anthropic --model claude-3-sonnet-20240229 --set-default

# Use custom configuration
drgpt --config ~/.drgpt-work-config "Work-related question"

Troubleshooting Commands

# Debug mode
drgpt --debug "Your question"

# Test provider connectivity
drgpt --provider openai --test

# Verbose output
drgpt --verbose "Your question"

Combining Options

Multiple options can be combined:

# Code generation with specific provider and output
drgpt --provider anthropic --code --output webapp.py "Create a Flask web application"

# Shell command with debug and custom timeout
drgpt --shell --debug --timeout 60 "Complex system maintenance task"

# Interactive mode with specific provider
drgpt --interface --provider openai --model gpt-4

Option Precedence

When the same setting is specified in multiple places, DrGPT uses this precedence order:

  1. Command-line options (highest precedence)

  2. Environment variables

  3. Configuration file

  4. Built-in defaults (lowest precedence)

Example:

# Environment variable
export DRGPT_DEFAULT_PROVIDER="anthropic"

# Command-line override (takes precedence)
drgpt --provider openai "Your question"  # Uses OpenAI, not Anthropic

Shell Integration

DrGPT works well with shell features:

Pipes

# Pipe file content
cat error.log | drgpt "Analyze this error log"

# Chain with other commands
drgpt --no-markdown "Brief answer" | grep "keyword"

Command Substitution

# Use DrGPT output in variables
EXPLANATION=$(drgpt --no-markdown "Explain $TERM")

# Use in other commands
echo "AI says: $(drgpt --no-markdown 'Brief answer')"

Scripting

#!/bin/bash
# Script example

# Check if DrGPT is available
if ! command -v drgpt &> /dev/null; then
    echo "DrGPT not found"
    exit 1
fi

# Get AI assistance
ADVICE=$(drgpt --no-markdown --provider openai "How to optimize $1")
echo "Optimization advice: $ADVICE"

See Also