cmd

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: MIT Imports: 16 Imported by: 0

README

cmd

Run and organize code snippets in markdown files

docs:update-demos
docker run -it --rm -v $(pwd)/demos:/demos $(docker build -q -f ./record-demo.Dockerfile .) /demos/record-script.sh /demos/intro/intro.script /demos/intro/intro.cast
docker run -it --rm -v $(pwd)/demos:/demos $(docker build -q -f ./record-demo.Dockerfile .) asciinema upload /demos/intro/intro.cast
code:test
go test ./...

Documentation

Index

Constants

View Source
const DefaultLanguage = "bash"

Variables

View Source
var BuildID string = "unknown"

Functions

func UpWhere

func UpWhere(initialDir, marker string) (string, error)

Types

type Command

type Command struct {
	Alias string
	Group string

	Help       string
	Definition string

	RenderCheckCmd func(ctx context.Context) *exec.Cmd

	SetExecFlags  func(f *flag.FlagSet)
	RenderExecCmd func(ctx context.Context, f *flag.FlagSet, args ...interface{}) (*exec.Cmd, error)
}

func ParseCommands

func ParseCommands(source []byte) ([]*Command, error)

func (*Command) Check

func (c *Command) Check(ctx context.Context) (string, error)

func (*Command) Execute

func (c *Command) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus

func (*Command) Name

func (c *Command) Name() string

func (*Command) SetFlags

func (c *Command) SetFlags(f *flag.FlagSet)

func (*Command) Synopsis

func (c *Command) Synopsis() string

func (*Command) Usage

func (c *Command) Usage() string

type CommandDefinition

type CommandDefinition struct {
	InputPath            string
	DeclaretionLineStart int

	Source           []byte
	Name             string
	HeadingStart     int
	HeadingStop      int
	HelpStart        int
	HelpStop         int
	DeclarationStart int
	DeclarationStop  int
	Declaration      *mdast.FencedCodeBlock
}

func ParseCommandDefinitions

func ParseCommandDefinitions(source []byte) ([]CommandDefinition, error)

func (*CommandDefinition) Parse

func (d *CommandDefinition) Parse() (*Command, error)

func (*CommandDefinition) ParseCommand

func (d *CommandDefinition) ParseCommand() string

func (*CommandDefinition) ParseDefinition

func (d *CommandDefinition) ParseDefinition() string

func (*CommandDefinition) ParseHelp

func (d *CommandDefinition) ParseHelp() string

func (*CommandDefinition) ParseInfo

func (d *CommandDefinition) ParseInfo() (string, map[string]string)

type ShellCommand

type ShellCommand struct {
	Exports map[string]*ShellValue
	Locals  map[string]*ShellValue

	LocalDeclarations map[string]*syntax.ParamExp

	File *syntax.File
}

func NewShellCommand

func NewShellCommand(shell string) (*ShellCommand, error)

func (*ShellCommand) Print

func (c *ShellCommand) Print() (string, error)

func (*ShellCommand) Render

func (c *ShellCommand) Render(locals map[string]*ShellValue) (string, error)

type ShellValue

type ShellValue struct {
	Literal    string
	Expression string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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