cli

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 41 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli is the command table, argument parsing, help and error handling of `ce`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseID

func ParseID(value, what string) (int64, error)

ParseID parses a positive integer ID, or exits 2.

func Projects

func Projects(c *api.Client) ([]map[string]any, error)

Projects calls GET /v1/projects.

func QuotePath

func QuotePath(goos, path string) string

QuotePath quotes a program path for the shell of the system: POSIX quotes on macOS and Linux; on Windows, double quotes when the path has a space or a special character of cmd.

func Run

func Run(argv []string, h *host.Host) int

Run runs `ce argv...` and returns the exit code.

Types

type Command

type Command struct {
	// Path is for example ["issue", "list"].
	Path    []string
	Summary string
	// Usage shows the arguments and options, for example "<id> [--section <name>]".
	Usage string
	// Details are the option lines of the help.
	Details []string
	Options map[string]Kind
	// Args are the names of the positional arguments. A name in brackets is optional; a last
	// name like "[path...]" takes any number of arguments.
	Args []string
	Run  func(s *Session) error
	// Docs is the docs section of the command: its errors link to it unless they have their own.
	Docs docs.Topic
	// Hidden commands are old names that still work for one release; help does not show them.
	Hidden bool
}

Command is one command, for example `ce issue list`.

func Commands

func Commands() []*Command

Commands is the command table, for the tests.

type Exit

type Exit int

Exit ends a command with an exit code and no error message (the command printed its result).

func (Exit) Error

func (e Exit) Error() string

type Kind

type Kind int

Kind is the type of an option.

const (
	// String takes a value: --name value or --name=value.
	String Kind = iota
	// Bool takes no value.
	Bool
	// List takes a value and can be given more than once.
	List
)

type Session

type Session struct {
	Host *host.Host
	Out  *output.Output
	Args []string
	// contains filtered or unexported fields
}

Session is one run of a command: parsed arguments, output and lazy access to the API.

func (*Session) API

func (s *Session) API() (*api.Client, error)

API returns a client with a token, or exit 5 with the next step.

func (*Session) AgentToken

func (s *Session) AgentToken(url string) (string, error)

AgentToken is the agent token for `ce mcp`: CHECKEND_AGENT_TOKEN, else the saved agent token of the linked app, else the only agent token of the instance. Never the login of a person.

func (*Session) Bool

func (s *Session) Bool(name string) bool

Bool returns a flag.

func (*Session) Has

func (s *Session) Has(name string) bool

Has reports whether an option was given.

func (s *Session) Link() (*config.Link, error)

Link returns the project link of the repo, or nil.

func (*Session) List

func (s *Session) List(name string) []string

List returns all values of a List option.

func (*Session) Project

func (s *Session) Project(c *api.Client, ref string) (map[string]any, error)

Project finds a project by public ID or slug, or exits 3.

func (*Session) ProjectFilter

func (s *Session) ProjectFilter() (string, error)

ProjectFilter is the project for a ?project= filter. The server takes the public ID or the slug (lowercase), so no lookup is needed.

func (*Session) ProjectRef

func (s *Session) ProjectRef() (string, error)

ProjectRef is the project from --project or .checkend.json, or "".

func (*Session) String

func (s *Session) String(name string) string

String returns an option value, or "".

func (*Session) Token

func (s *Session) Token(url string) (string, error)

Token returns the token for url ("" when none) and hides it in the output. Without a login, it is the agent token of the linked app (from `ce setup`).

func (*Session) URL

func (s *Session) URL() (string, error)

URL returns the instance URL, or exit 5 with the next step.

Jump to

Keyboard shortcuts

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