Skip to main content

Global Flags

These flags work with all commands:
FlagShortDescription
--config-cPath to configuration file
--help-hShow help for any command

Commands

cw-agent init

Initialize a new configuration file using an interactive wizard.
cw-agent init [flags]
Flags:
FlagShortDefaultDescription
--output-o./certwatch.yamlOutput file path
--non-interactivefalseUse environment variables instead of prompts
Examples:
# Interactive mode
cw-agent init

# Specify output path
cw-agent init -o /etc/certwatch/certwatch.yaml

# Non-interactive mode (for CI/CD)
CW_API_KEY=cw_xxx CW_CERTIFICATES=example.com \
  cw-agent init --non-interactive -o certwatch.yaml

cw-agent start

Start the monitoring agent.
cw-agent start [flags]
Flags:
FlagShortDefaultDescription
--config-c./certwatch.yamlPath to config file
--reset-agentfalseReset agent state and re-register
--yes-yfalseSkip confirmation prompts
Examples:
# Start with default config
cw-agent start

# Start with specific config
cw-agent start -c /etc/certwatch/certwatch.yaml

# Reset agent (creates new agent, migrates certificates)
cw-agent start -c certwatch.yaml --reset-agent

# Reset without confirmation (for CI/automation)
cw-agent start -c certwatch.yaml --reset-agent --yes
Agent State: The agent persists its state in .certwatch-state.json alongside your config file. This enables:
  • Restart resilience - Agent ID survives restarts
  • Name change detection - Warns if you change agent.name in config
  • Certificate migration - When resetting, certificates transfer to new agent

cw-agent validate

Validate configuration without starting the agent.
cw-agent validate [flags]
Flags:
FlagShortDefaultDescription
--config-c./certwatch.yamlPath to config file
Example:
cw-agent validate -c certwatch.yaml
Output:
CertWatch Agent - Config Validation

[✓] Configuration loaded
[✓] API settings valid
[✓] Agent settings valid
[✓] 5 certificates configured

Summary
  Agent         production-monitor
  Certificates  5
  Sync          5m
  Scan          1m

[✓] Configuration is valid!

cw-agent version

Display version information.
cw-agent version
Output:
CertWatch Agent v0.2.1

  Version     v0.2.1
  Commit      abc1234
  Build Date  2025-01-01
  Go Version  go1.22.0
  Platform    linux/amd64

Exit Codes

CodeDescription
0Success
1General error (config invalid, connection failed, etc.)
130Interrupted (Ctrl+C)

Signals

The agent handles the following signals gracefully:
SignalBehavior
SIGINT (Ctrl+C)Graceful shutdown
SIGTERMGraceful shutdown
SIGHUPReload configuration (planned)