cli

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package cli provides all CLI commands centian offers, including init, stdio, server, logs, config and all of their sub-commands.

Index

Constants

View Source
const Fish string = "fish"

Fish is an animal living underwater...

Variables

View Source
var AuthCommand = &cli.Command{
	Name:  "auth",
	Usage: "Manage Centian authentication",
	Commands: []*cli.Command{
		AuthNewKeyCommand,
	},
}

AuthCommand provides authentication utilities.

View Source
var AuthNewKeyCommand = &cli.Command{
	Name:  "new-key",
	Usage: "centian auth new-key",
	Description: `Generate a new API key for the HTTP proxy.

The key is printed once to the console, then hashed with bcrypt and stored in:
  ~/.centian/api_keys.json
`,
	Action: handleAuthNewKeyCommand,
}

AuthNewKeyCommand generates and stores a new API key.

View Source
var InitCommand = &cli.Command{
	Name:        "init",
	Usage:       "Initialize centian with default configuration",
	Description: "Creates ~/.centian/config.json with default settings and guides initial setup",
	Action:      initCentian,
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:    "quickstart",
			Aliases: []string{"q"},
			Usage:   "Create a ready-to-run config (requires npx)",
		},
		&cli.BoolFlag{
			Name:    "force",
			Aliases: []string{"f"},
			Usage:   "Overwrite existing configuration if it exists",
		},
		&cli.StringFlag{
			Name:    "from-path",
			Aliases: []string{"p"},
			Usage:   "Import servers from a specific MCP config file path",
		},
	},
}

InitCommand initializes a new centian setup with default configuration.

View Source
var LogsCommand = &cli.Command{
	Name:  "logs",
	Usage: "Displays logs: centian logs [--limit <n>]",
	Description: `Display formatted Centian MCP proxy logs ordered by timestamp (newest first).

Examples:
  centian logs
  centian logs --limit 10`,
	Flags: []cli.Flag{
		&cli.IntFlag{
			Name:  "limit",
			Usage: "Number of log entries to display (0 shows all)",
			Value: defaultLogDisplayLimit,
		},
	},
	Action: handleLogsCommand,
}

LogsCommand displays Centian log entries in descending timestamp order.

View Source
var ProcessorAddCommand = &cli.Command{
	Name:        "add",
	Usage:       "Add a processor to the configuration",
	Description: "Register a processor script in the global config. Name is inferred from the filename unless --name is provided.",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:     "path",
			Aliases:  []string{"p"},
			Usage:    "Path to the processor script",
			Required: true,
		},
		&cli.StringFlag{
			Name:    "name",
			Aliases: []string{"n"},
			Usage:   "Processor name (default: inferred from filename)",
		},
		&cli.StringFlag{
			Name:    "type",
			Aliases: []string{"t"},
			Usage:   "Processor type",
			Value:   "cli",
		},
	},
	Action: handleProcessorAdd,
}

ProcessorAddCommand registers an existing processor script in the global config.

View Source
var ProcessorCommand = &cli.Command{
	Name:  "processor",
	Usage: "Manage Centian processors",
	Commands: []*cli.Command{
		ProcessorInitCommand,
		ProcessorAddCommand,
	},
}

ProcessorCommand provides processor management functionality.

View Source
var ProcessorInitCommand = &cli.Command{
	Name:        "new",
	Usage:       "centian processor new",
	Description: "Interactively scaffold a new processor.",
	Action:      handleProcessorInit,
}

ProcessorInitCommand scaffolds a new processor.

View Source
var StartCommand = &cli.Command{
	Name:  "start",
	Usage: "Start Centian proxy: centian start [--config-path <path>]",
	Description: `Start Centian proxy server for configured MCP servers.

Currently supports HTTP transport. The HTTP proxy creates endpoints for each
configured HTTP MCP server at:
  /mcp/<gateway_name>/<server_name>

Configuration is loaded from ~/.centian/config.json by default.

Example config structure:
  {
    "version": "1.0.0",
    "name": "My Centian Server",
    "proxy": {
      "port": "8080",
      "timeout": 30
    },
    "gateways": {
      "my-gateway": {
        "mcpServers": {
          "github": {
            "url": "https://api.githubcopilot.com/mcp/",
            "headers": {
              "Authorization": "Bearer ${MY_GH_TOKEN_ENV_VAR}"
            }
          }
        }
      }
    }
  }

Examples:
  centian start
  centian start --config-path ./custom-config.json
`,
	Action: handleServerStartCommand,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "config-path",
			Usage: "Path to config file (default: ~/.centian/config.json)",
		},
	},
}

StartCommand starts the Centian proxy server.

Functions

func SetupShellCompletion

func SetupShellCompletion() error

SetupShellCompletion offers to set up shell completion for the user.

Types

type InitOption

type InitOption int

InitOption represents the user's choice for initialization method.

const (
	// InitOptionEmpty creates an empty config with no servers.
	InitOptionEmpty InitOption = iota
	// InitOptionQuickstart creates a ready-to-run config with a default MCP server.
	InitOptionQuickstart
	// InitOptionDiscovery auto-discovers existing MCP servers.
	InitOptionDiscovery
	// InitOptionFromPath imports servers from a specific config file.
	InitOptionFromPath
)

type InitUI

type InitUI struct {
	// contains filtered or unexported fields
}

InitUI provides user interface functions for the init command.

func NewInitUI

func NewInitUI() *InitUI

NewInitUI creates a new init UI interface.

type ShellInfo

type ShellInfo struct {
	Name           string // bash, zsh, fish, etc.
	RCFile         string // path to RC file (~/.bashrc, ~/.zshrc, etc.)
	CompletionLine string // the line to add for completion
}

ShellInfo contains information about the current shell and its configuration.

func DetectShell

func DetectShell() (*ShellInfo, error)

DetectShell detects the current shell and returns shell information.

Jump to

Keyboard shortcuts

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