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 --update
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_*
treeDisplay dependency treecforge tree --depth 3
newGenerate code from templatescforge new class MyClass
completionsGenerate shell completionscforge completions bash

Project Management

CommandDescriptionExample
addAdd a dependency to the projectcforge add fmt
removeRemove a dependencycforge remove spdlog
updateUpdate dependenciescforge update
lockLock dependency versionscforge lock
listList variants, configs, or targetscforge list variants
ideGenerate IDE project filescforge ide vscode
vcpkgManage vcpkg integrationcforge vcpkg install

Utility Commands

CommandDescriptionExample
versionDisplay version informationcforge version
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

tree

Display the project's dependency tree.

# Show dependency tree
cforge tree

# Limit depth
cforge tree --depth 2

# Show all details
cforge tree -v

Output:

my_app v1.0.0
├── fmt (10.1.0) [vcpkg]
├── spdlog (1.12.0) [vcpkg]
│ └── fmt (10.1.0) [vcpkg]
└── my_lib (local) [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

Manage project dependencies.

# Show dependencies
cforge deps

# Update all dependencies
cforge deps --update

# Check for outdated
cforge deps --check

add / remove

Manage dependencies in cforge.toml.

# Add a vcpkg dependency
cforge add fmt

# Add with version
cforge add "spdlog@1.12.0"

# Remove a dependency
cforge remove spdlog

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