spec

package module
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 22 Imported by: 0

README

carapace-spec

PkgGoDev GoReportCard documentation Coverage Status Packaging status

Define simple completions using a spec file (based on carapace).

The carapace-spec binary can be used to complete spec files, but carapace-bin is recommended as it supports a range of custom macros.

name: mycmd
description: my command
flags:
  --optarg?: optarg flag
  -r, --repeatable*: repeatable flag
  -v=: flag with value
persistentflags:
  --help: bool flag
completion:
  flag:
    optarg: ["one", "two\twith description", "three\twith style\tblue"]
    v: ["$files"]
commands:
- name: sub
  description: subcommand
  completion:
    positional:
      - ["$list(,)", "1", "2", "3"]
      - ["$directories"]

Generators

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionMacro added in v0.0.14

func ActionMacro(s string) carapace.Action

ActionMacro completes given macro

func ActionSpec added in v0.0.16

func ActionSpec(path string) carapace.Action

ActionSpec completes a spec

func AddMacro

func AddMacro(s string, m Macro)

AddMacro adds a custom macro

func Codegen added in v0.14.0

func Codegen(cmd *cobra.Command) error

func NewAction added in v0.10.0

func NewAction(s []string) action

func Register added in v0.12.0

func Register(cmd *cobra.Command)

func Schema added in v0.1.2

func Schema() (string, error)

Schema returns a json schema with currently registered macros

Types

type Command

type Command command.Command

func (Command) Codegen added in v0.14.0

func (c Command) Codegen() error

func (Command) ToCobra

func (c Command) ToCobra() *cobra.Command

func (Command) ToCobraE added in v0.5.0

func (c Command) ToCobraE() (*cobra.Command, error)

type Macro

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

func MacroI

func MacroI[T any](f func(t T) carapace.Action) Macro

func MacroN

func MacroN(f func() carapace.Action) Macro

func MacroV added in v0.0.13

func MacroV[T any](f func(t ...T) carapace.Action) Macro

func (Macro) Parse added in v0.11.0

func (m Macro) Parse(s string) carapace.Action

func (Macro) Signature added in v0.0.10

func (m Macro) Signature() string

Directories

Path Synopsis
cmd
internal
pkg

Jump to

Keyboard shortcuts

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