cli

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: GPL-3.0 Imports: 50 Imported by: 0

Documentation

Overview

Package cli implements span's command line: one binary, one cobra command per verb.

span used to install one executable per tool (span-import, span-tag, ...). The old names survive as symlinks to the single "span" binary. It looks at the name it was invoked under and runs the matching verb, so existing scripts, cron jobs and siskin tasks keep working unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dispatch

func Dispatch(argv []string) (args []string, legacy bool)

Dispatch maps an invocation under a legacy name onto the command path that replaces it. argv is the whole command line, argv[0] included; it returns the args for the root command and whether a legacy name was used.

func Main

func Main()

Main runs span and exits with a non-zero status on error.

func NewRoot

func NewRoot() *cobra.Command

NewRoot builds the command tree.

func RewriteArgs

func RewriteArgs(root *cobra.Command, args []string, legacy bool) []string

RewriteArgs bridges the stdlib flag package the legacy tools used and the pflag package cobra uses. With stdlib flags, "-unfreeze f" and "--unfreeze f" are the same thing, and so are "-o x" and "--o x". pflag reads "-unfreeze" as a cluster of shorthands and knows single letters only as shorthands, so long names get a second dash and single letters lose one.

Under a legacy name every single-dash multi-letter token is rewritten, since the stdlib flag package had no clusters. Under "span" itself only known flags are rewritten, so that clusters like "-bf" keep working.

Types

This section is empty.

Jump to

Keyboard shortcuts

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