Complete command-line interface for czg providing interactive commit message generation with extensive customization options.
Entry point for the czg CLI that handles argument parsing and command routing.
/**
* Main CLI Entry Point - processes command line arguments and starts interactive commit
* @param environment - Optional environment configuration object
* @param argv - Command line arguments array (defaults to process.argv)
*/
function main(environment?: any, argv?: string[]): void;Usage Examples:
# Basic usage - starts interactive commit process
czg
# With specific git arguments passed through
czg --amend
czg --no-verifyThe main function that starts the interactive commit process after argument parsing.
/**
* Start inquirer prompts to generate commit message
* @param version - Current czg version string
* @param argvs - Parsed CLI arguments structure
* @param environment - Optional environment configuration
*/
function czg(version: string, argvs: CzgitParseArgs, environment?: any): void;Parses command line arguments into structured format for processing.
/**
* Parse CLI arguments using minimist into structured format
* @param argv - Raw command line arguments
* @returns Structured parsed arguments with czg and git sections
*/
function resovleArgs(argv: string[]): CzgitParseArgs;Turn on OpenAI-powered commit message generation.
# Basic AI mode
czg ai
# AI mode with multiple suggestions
czg ai -N=3
# AI mode with specific model
czg ai -M="gpt-4o"
# Combined AI options
czg ai -N=5 -M="gpt-3.5-turbo"Enable emoji output in commit messages.
czg emojiTurn on scope selection via checkboxes instead of list.
czg checkboxAutomatically append ! after type/scope to indicate breaking changes.
czg breakEnable GPG signing for the commit.
czg gpgConfigure czg settings (currently not implemented).
czg init# Use specific configuration file
czg --config="./config/cz.json"
czg --config="/path/to/custom.config.js"
# Direct commit with predefined alias
czg --alias="feat: add new feature"
czg :feat # Shorthand alias syntax# Set OpenAI API key
czg --api-key="sk-xxx"
# Configure API model
czg --api-model="gpt-4o"
# Set API endpoint
czg --api-endpoint="https://api.openai.com/v1"
# Configure proxy
czg --api-proxy="http://proxy.example.com:8080"
# Remove proxy configuration
czg --unset-proxy
# Disable AI for this session
czg --no-ai
# AI options for current session
czg -N=3 -M="gpt-4o" # 3 suggestions, gpt-4o model# Retry last commit attempt
czg --retry
czg -r
# Hook mode (for git hooks integration)
czg --hook
# Reback last commit (not implemented)
czg --reback
czg -b# Show help information
czg --help
czg -h
# Show version
czg --version
czg -vAll unrecognized arguments are passed through to git commit:
# These git flags are passed through to git commit
czg --amend
czg --no-verify
czg --author="John Doe <john@example.com>"
czg -a # Stage all files before commit
czg --allow-emptyInternal functions for git operations:
/**
* Check if git working directory is clean
* @param repoPath - Path to git repository
* @param done - Callback function receiving (error, isClean)
* @param stageAllFiles - Whether to check for unstaged files too
*/
function isGitClean(repoPath: string, done: CallBackFn, stageAllFiles: boolean): void;
/**
* Get the root path of the current git repository
* @returns Git repository root path
*/
function getGitRootPath(): string;
/**
* Get the absolute path to the .git directory
* @param pwd - Current working directory
* @returns Absolute path to .git directory
*/
function getGitDirPath(pwd: string): string;
/**
* Execute git commit with the provided message and options
* @param repoPath - Path to git repository
* @param message - Commit message to use
* @param options - Commit configuration options
* @param done - Callback function for completion
*/
function gitCommit(repoPath: string, message: string, options: CommitOptions, done: CallBackFn): void;Built-in help system with comprehensive usage information.
/**
* Generate and display help documentation
* @param version - Current czg version
* @param code - Exit code (default: 0)
*/
function generateHelp(version: string, code?: number): void;The help system displays:
/**
* Setup OpenAI API configuration in user's home directory
* @param token - OpenAI API token/key
* @param apiProxy - API proxy URL
* @param unsetProxy - Whether to remove proxy configuration
* @param apiEndpoint - Custom API endpoint
* @param apiModel - Default AI model to use
*/
function setupAIConfig(
token?: string,
apiProxy?: string,
unsetProxy?: boolean,
apiEndpoint?: string,
apiModel?: string
): void;Configuration is stored in ~/.config/.czrc as JSON:
{
"openAIToken": "sk-xxx",
"apiProxy": "http://proxy.example.com:8080",
"apiEndpoint": "https://api.openai.com/v1",
"apiModel": "gpt-4o"
}czg includes comprehensive error handling:
czg recognizes several environment variables:
CZ_ALL_CHANGE_MODE: Set to '1' when using -a or --all flagsCZCommitSignGPG: Set to '1' to enable GPG signing