synopsis

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2025 The Joe-cli Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Copyright 2025 The Joe-cli Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

View Source
const (
	OnlyShortNoValue         = OptionGroup(iota) // -v
	OnlyShortNoValueOptional                     // [-v]
	OtherOptional                                // [--long=value]
	Other                                        // --long=value
	ActionGroup                                  // { --help|--version}
	Hidden
)
View Source
const (
	Bold      = ansiterm.Bold
	Underline = ansiterm.Underline
)

Variables

This section is empty.

Functions

func ArgCounter

func ArgCounter(narg any) (optional, multi bool)

func Placeholder

func Placeholder(v any) string

Types

type Arg

type Arg struct {
	Value    string
	Multi    bool
	Optional bool
}

func NewArg

func NewArg(usage string, narg any) *Arg

func (*Arg) WithUsage

func (a *Arg) WithUsage(text string) *Arg

func (*Arg) WriteTo

func (a *Arg) WriteTo(sb styleWriter)

type Command

type Command struct {
	Name         string
	Flags        map[OptionGroup][]*Flag
	Args         []*Arg
	RequiredArgs []*Arg
	OptionalArgs []*Arg
	RTL          bool
}

func NewCommand

func NewCommand(name string, flags []*Flag, args []*Arg, rtl bool) *Command

func (*Command) WriteTo

func (c *Command) WriteTo(sb styleWriter)

type Expr

type Expr struct {
	Long         string
	Short        string
	Usage        *Usage
	Names        []string
	Args         []*Arg
	RequiredArgs []*Arg
	OptionalArgs []*Arg
}

func NewExpr

func NewExpr(primary string, aliases []string, usage *Usage, args []*Arg) *Expr

func (*Expr) WriteTo

func (e *Expr) WriteTo(sb styleWriter)

type Flag

type Flag struct {
	Short          string
	Shorts         []rune
	Long           string
	Primary        string // Long if present, otherwise Short
	Separator      string
	Names          []string
	AlternateNames []string
	Value          *Value
	Group          OptionGroup
}

func NewFlag

func NewFlag(primary string, aliases []string, helpText, usageString string, v any, group OptionGroup) *Flag

func (*Flag) WithNo

func (f *Flag) WithNo()

func (*Flag) WriteTo

func (f *Flag) WriteTo(sb styleWriter)

type OptionGroup

type OptionGroup int

type Stringer

type Stringer interface {
	WriteTo(styleWriter)
}

type Usage

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

func ParseUsage

func ParseUsage(text string) *Usage

func (*Usage) HelpText

func (u *Usage) HelpText(w styleWriter)

func (*Usage) Placeholders

func (u *Usage) Placeholders() []string

func (*Usage) WithoutPlaceholders

func (u *Usage) WithoutPlaceholders() string

type Value

type Value struct {
	Placeholder string

	Usage *Usage
	// contains filtered or unexported fields
}

func (*Value) WriteTo

func (v *Value) WriteTo(w styleWriter)

Jump to

Keyboard shortcuts

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