Skip to main content

Command Reference

CForge provides a comprehensive set of commands for building, testing, and managing C/C++ projects.

Core Commands

CommandDescriptionExample
initCreate new project/workspacecforge init --template lib
buildBuild the projectcforge build --config Release
cleanClean build artifactscforge clean
runRun built executablecforge run -- arg1 arg2
testExecute tests (CTest integration)cforge test --filter MyTest
installInstall project binariescforge install --prefix /usr/local
depsManage dependenciescforge deps add fmt
packagePackage project binariescforge package --type zip

Developer Tools

CommandDescriptionExample
fmtFormat code with clang-formatcforge fmt --check
lintRun clang-tidy static analysiscforge lint --fix
watchWatch files and rebuild on changescforge watch --run
docGenerate documentation with Doxygencforge doc --open
benchRun benchmarkscforge bench --filter BM_*
newGenerate code from templatescforge new class MyClass
completionsGenerate shell completionscforge completions bash

Dependency Management

All dependency operations use the unified cforge deps command:

SubcommandDescriptionExample
deps addAdd a dependency to the projectcforge deps add fmt@11.1.4
deps removeRemove a dependencycforge deps remove spdlog
deps searchSearch package registrycforge deps search json
deps infoShow package detailscforge deps info spdlog --versions
deps listList current dependenciescforge deps list
deps treeDisplay dependency treecforge deps tree --depth 3
deps lockManage lock filecforge deps lock --verify
deps updateUpdate package registrycforge deps update
deps outdatedShow outdated dependenciescforge deps outdated

Project Management

CommandDescriptionExample
ideGenerate IDE project filescforge ide vscode
cacheManage binary cachecforge cache stats
circularDetect circular include dependenciescforge circular

Utility Commands

CommandDescriptionExample
versionDisplay version informationcforge version
upgradeUpgrade cforge to latest versioncforge upgrade
doctorDiagnose environment issuescforge doctor
helpShow help for commandscforge help build

Global Options

All commands accept these global options:

OptionDescription
-v, --verboseEnable verbose output
-q, --quietSuppress non-essential output
-c, --configBuild configuration (Debug, Release, etc.)

Command Details

init

Create a new cforge project or workspace.

# Create a project in current directory
cforge init

# Create a named project
cforge init my_project

# Create with options
cforge init --name=my_project --cpp=20 --with-tests --with-git

# Create a workspace with projects
cforge init --workspace my_workspace --projects app lib tests

Options:

OptionDescription
--nameSet project name
--workspaceCreate a workspace
--projectsCreate multiple projects
--cppSet C++ standard (11, 14, 17, 20, 23)
--templateUse template (exe, lib, header-only)
--with-testsAdd test infrastructure
--with-gitInitialize Git repository

build

Build the project using CMake.

# Debug build (default)
cforge build

# Release build
cforge build --config Release

# Verbose output
cforge build -v

Output:

   Compiling my_app v1.0.0
Compiling src/main.cpp
Compiling src/utils.cpp
Finished Debug target(s) in 2.34s

run

Build and run the executable.

# Run the default target
cforge run

# Pass arguments
cforge run -- --help --verbose

# Run specific target
cforge run my_target

test

Run tests using CTest.

# Run all tests
cforge test

# Filter tests
cforge test --filter "Unit*"

# Verbose output
cforge test -v

fmt

Format source code using clang-format.

# Format all files
cforge fmt

# Check formatting (no changes)
cforge fmt --check

# Format specific path
cforge fmt src/

Requirements: clang-format must be installed and available in PATH.

lint

Run static analysis using clang-tidy.

# Analyze all files
cforge lint

# Auto-fix issues
cforge lint --fix

# Specific checks
cforge lint --checks="modernize-*"

Requirements: clang-tidy must be installed and available in PATH.

watch

Watch for file changes and automatically rebuild.

# Watch and rebuild
cforge watch

# Watch and run after build
cforge watch --run

# Custom poll interval
cforge watch --interval 2

Press Ctrl+C to stop watching.

doc

Generate documentation using Doxygen.

# Generate documentation
cforge doc

# Initialize Doxyfile
cforge doc --init

# Generate and open in browser
cforge doc --open

Requirements: Doxygen must be installed and available in PATH.

bench

Run benchmark executables.

# Run all benchmarks
cforge bench

# Filter benchmarks
cforge bench --filter "BM_Sort*"

# Output formats
cforge bench --json
cforge bench --csv

# Skip build step
cforge bench --no-build

deps tree

Display the project's dependency tree.

# Show dependency tree
cforge deps tree

# Limit depth
cforge deps tree --depth 2

# Show all details
cforge deps tree -a

Output:

my_app v1.0.0
├── fmt @ 10.1.0 (index)
├── spdlog @ 1.12.0 (index)
│ └── fmt @ 10.1.0 (index)
└── my_lib (project)

Dependencies: 2 index, 1 project

new

Generate code from templates.

# Create a class
cforge new class MyClass

# Create a header file
cforge new header utils

# Create with namespace
cforge new class MyClass -n myapp

# Create a test file
cforge new test MyClassTest

# Available templates: class, header, struct, interface, test, main

completions

Generate shell completion scripts.

# Bash
cforge completions bash > ~/.local/share/bash-completion/completions/cforge

# Zsh
cforge completions zsh > ~/.zfunc/_cforge

# PowerShell
cforge completions powershell >> $PROFILE

# Fish
cforge completions fish > ~/.config/fish/completions/cforge.fish

ide

Generate IDE project files.

# VS Code
cforge ide vscode

# CLion
cforge ide clion

# Visual Studio
cforge ide vs

# Xcode (macOS only)
cforge ide xcode

deps

Unified dependency management command. All dependency operations use cforge deps <subcommand>.

# Show all deps subcommands
cforge deps --help

# List current dependencies
cforge deps list

# Check for outdated dependencies
cforge deps outdated

# Update package registry
cforge deps update

Search the cforge package registry.

# Search for packages
cforge deps search json

# Search for logging libraries
cforge deps search log

deps info

Get detailed information about a package.

# Show package info
cforge deps info spdlog

# Show available versions
cforge deps info fmt --versions

deps add / deps remove

Manage dependencies in cforge.toml.

# Add from registry (default)
cforge deps add fmt

# Add with specific version
cforge deps add fmt@11.1.4

# Add with features
cforge deps add spdlog --features async

# Add from Git
cforge deps add mylib --git https://github.com/user/mylib --tag v1.0

# Add from vcpkg
cforge deps add boost --vcpkg

# Remove a dependency
cforge deps remove spdlog

Options:

OptionDescription
@versionSpecify version (e.g., fmt@11.1.4)
--git <url>Add as Git dependency
--tag <tag>Git tag (with --git)
--branch <name>Git branch (with --git)
--vcpkgAdd as vcpkg package
--features <list>Comma-separated features
--header-onlyMark as header-only library

deps outdated

Check for dependencies with newer versions available.

# Show outdated dependencies
cforge deps outdated

Output:

Package         Current    Latest     Source
-------------- --------- --------- ------
fmt 11.1.4 12.1.0 index
spdlog 1.12.0 1.15.0 index

Found 2 outdated package(s)

deps lock

Manage dependency lock file for reproducible builds.

# Generate/update lock file
cforge deps lock

# Verify dependencies match lock
cforge deps lock --verify

# Force regeneration
cforge deps lock --force

# Remove lock file
cforge deps lock --clean

package

Create distributable packages.

# Create a ZIP package
cforge package --type zip

# Create installer (platform-specific)
cforge package --type installer

list

List project information.

# List build variants
cforge list variants

# List targets
cforge list targets

# List configurations
cforge list configs