spec

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 22 Imported by: 3

README

[!IMPORTANT] In the process of moving to github.com/carapace-sh

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

func ActionMacro(s string) carapace.Action

ActionMacro completes given macro

func ActionSpec

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

func Codegen(cmd *cobra.Command) error

func NewAction

func NewAction(s []string) action

func Register

func Register(cmd *cobra.Command)

func Schema

func Schema() (string, error)

Schema returns a json schema with currently registered macros

Types

type Command

type Command command.Command

func (Command) Codegen

func (c Command) Codegen() error

func (Command) ToCobra

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

func (Command) ToCobraE

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

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

func (Macro) Parse

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

func (Macro) Signature

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