CLI Tools
Infrahub includes two primary CLI tools:infrahubctl
The main CLI tool for interacting with Infrahub. It provides commands for:- Database management and migrations
- Server control and debugging
- Interactive shell access
- System upgrades
- Development utilities
infrahub (Python Package)
Theinfrahub Python package CLI is primarily used for server operations and is accessed via:
infrahubctl for day-to-day operations.
Installation
The Infrahub CLI is installed automatically when you install Infrahub:infrahubctl command available in your environment.
Configuration
Most CLI commands accept a configuration file path:INFRAHUB_CONFIG environment variable:
infrahub.toml in the current directory.
Command Structure
Infrahub CLI commands follow a hierarchical structure:Common Options
Most commands support these common options:| Option | Description | Default |
|---|---|---|
--help | Show help message and exit | - |
--debug | Enable debug logging | False |
config_file | Path to configuration file | infrahub.toml |
Command Categories
Database Commands
Manage the graph database, run migrations, and perform maintenance:infrahubctl db migrate- Apply database migrationsinfrahubctl db constraint- Manage database constraintsinfrahubctl db index- Manage database indexesinfrahubctl db check- Run database health checks
Server Commands
Control the Infrahub API server:infrahubctl server start- Start the API server in debug mode
Development Commands
Utilities for development and testing:infrahubctl dev db-init- Initialize a fresh databaseinfrahubctl dev export-graphql-schema- Export GraphQL schemainfrahubctl dev export-json-schema- Export OpenAPI schema
Getting Help
Every command and subcommand supports the--help flag:
Exit Codes
The CLI uses standard exit codes:0- Success1- Error or failure
Logging
The CLI outputs logs to stderr with varying levels of detail:- Default: INFO level messages
- Debug mode (
--debug): Detailed DEBUG level messages with timestamps
Next Steps
- infrahubctl Commands - Complete command reference
- Database Commands - Database management guide
- Server Commands - Server control guide