cli

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package cli wires the kong subcommand tree for the ccgate binary.

Layout:

ccgate                       (no args + stdin pipe) -> claude.Run     (permanent default)
ccgate claude                                       -> claude.Run     (explicit)
ccgate claude init                                  -> claude.Init
ccgate claude metrics                               -> claude.Metrics
ccgate init / ccgate metrics                        -> deprecated     (exit 2 with migration hint)

Bare `ccgate` is the canonical Claude Code hook invocation and will keep working forever — existing `~/.claude/settings.json` entries using `"command": "ccgate"` are not touched.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(version string, args []string, stdin io.Reader, stdout, stderr io.Writer) int

Run is the binary entry point. main() should call cli.Run with the process's args/stdin/stdout/stderr and propagate the returned exit code.

Types

type CLI

type CLI struct {
	Version kong.VersionFlag `help:"Print version and exit."`

	Claude  ClaudeCmd            `` /* 141-byte string literal not displayed */
	Codex   CodexCmd             `` /* 128-byte string literal not displayed */
	Clm     ClaudeMetricsCmd     `cmd:"" help:"Shortcut for 'ccgate claude metrics'."`
	Com     CodexMetricsCmd      `cmd:"" help:"Shortcut for 'ccgate codex metrics'."`
	Init    DeprecatedInitCmd    `cmd:"" help:"[removed in v0.6] Use 'ccgate claude init' or 'ccgate codex init' instead."`
	Metrics DeprecatedMetricsCmd `cmd:"" help:"[removed in v0.6] Use 'ccgate claude metrics' or 'ccgate codex metrics' instead."`
}

CLI is the kong-bound root command tree.

type ClaudeCmd

type ClaudeCmd struct {
	Hook    ClaudeHookCmd    `` /* 133-byte string literal not displayed */
	Init    ClaudeInitCmd    `cmd:""                                help:"Output the embedded Claude Code default configuration."`
	Metrics ClaudeMetricsCmd `cmd:""                                help:"Show Claude Code usage metrics."`
}

ClaudeCmd groups the Claude Code subcommands. Bare `ccgate claude` dispatches to the Hook sub-sub-command via kong's default mechanism; it is also the explicit equivalent of bare `ccgate`. Hook is left visible in --help so users can see that the bare invocation has a concrete entry point.

type ClaudeHookCmd

type ClaudeHookCmd struct{}

ClaudeHookCmd is a marker struct so kong has a "subcommand" to make default. The actual hook orchestration is dispatched in cli.go.

type ClaudeInitCmd

type ClaudeInitCmd struct {
	Project bool   `help:"Output the project-local configuration template instead of the global one." short:"p"`
	Output  string `help:"Write to FILE instead of stdout."                                            short:"o" type:"path"`
	Force   bool   `help:"Overwrite an existing file at --output."                                     short:"f"`
}

ClaudeInitCmd backs `ccgate claude init`.

type ClaudeMetricsCmd

type ClaudeMetricsCmd struct {
	Days    int  `default:"7"  help:"Show last N days."`
	JSON    bool `help:"Output as JSON."                                                          name:"json"`
	Details int  `default:"10" help:"Show top-N fallthrough/deny commands per section. Use 0 to hide both sections."`
}

ClaudeMetricsCmd backs `ccgate claude metrics`.

type CodexCmd

type CodexCmd struct {
	Hook    CodexHookCmd    `cmd:"" default:"withargs" name:"hook" help:"Run the Codex CLI hook from stdin (default; same as 'ccgate codex')."`
	Init    CodexInitCmd    `cmd:""                                help:"Output the embedded Codex CLI default configuration."`
	Metrics CodexMetricsCmd `cmd:""                                help:"Show Codex CLI usage metrics."`
}

CodexCmd groups the OpenAI Codex CLI subcommands. Bare `ccgate codex` dispatches to the Hook sub-sub-command via kong's default mechanism so users can wire that exact string into their Codex hook config. Hook is left visible in --help so users can see that the bare invocation has a concrete entry point.

type CodexHookCmd

type CodexHookCmd struct{}

CodexHookCmd is a marker struct so kong has a "subcommand" to make default. The actual hook orchestration is dispatched in cli.go.

type CodexInitCmd

type CodexInitCmd struct {
	Project bool   `help:"Output the project-local configuration template instead of the global one." short:"p"`
	Output  string `help:"Write to FILE instead of stdout."                                            short:"o" type:"path"`
	Force   bool   `help:"Overwrite an existing file at --output."                                     short:"f"`
}

CodexInitCmd backs `ccgate codex init`.

type CodexMetricsCmd

type CodexMetricsCmd struct {
	Days    int  `default:"7"  help:"Show last N days."`
	JSON    bool `help:"Output as JSON."                                                          name:"json"`
	Details int  `default:"10" help:"Show top-N fallthrough/deny commands per section. Use 0 to hide both sections."`
}

CodexMetricsCmd backs `ccgate codex metrics`.

type DeprecatedInitCmd

type DeprecatedInitCmd struct{}

DeprecatedInitCmd / DeprecatedMetricsCmd register the historical top-level subcommands so they no longer parse as unknown commands. Both intentionally accept no flags — the kong help text and the runtime error message both point users at the new per-target form.

type DeprecatedMetricsCmd

type DeprecatedMetricsCmd struct{}

DeprecatedInitCmd / DeprecatedMetricsCmd register the historical top-level subcommands so they no longer parse as unknown commands. Both intentionally accept no flags — the kong help text and the runtime error message both point users at the new per-target form.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL