cli

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout = time.Second * 30
)

Variables

This section is empty.

Functions

func Getwd

func Getwd() (string, error)

func NewBindingNode

func NewBindingNode(p *hype.Parser, el *hype.Element, whole *binding.Whole) (hype.Node, error)

func NewBindingNodes

func NewBindingNodes(whole *binding.Whole) hype.ParseElementFn

func NewParser

func NewParser(cab fs.FS, ctxPath string, pwd string) (*hype.Parser, error)

func WithTimeout

func WithTimeout(ctx context.Context, timeout time.Duration, f func(context.Context) error) error

func WithinDir

func WithinDir(dir string, f func() error) error

Types

type App

type App struct {
	cleo.Cmd

	Parser *hype.Parser
	// contains filtered or unexported fields
}

func Garlic

func Garlic(root string, info VersionInfo) (*App, error)

func New

func New(root string, info VersionInfo) *App

func (*App) Main

func (cmd *App) Main(ctx context.Context, pwd string, args []string) error

func (*App) ScopedPlugins

func (cmd *App) ScopedPlugins() plugins.Plugins

type Binding

type Binding struct {
	*hype.Element

	Whole *binding.Whole
}

func (*Binding) String

func (b *Binding) String() string

type Blog added in v0.5.0

type Blog struct {
	cleo.Cmd

	Timeout time.Duration
	Verbose bool
	Info    VersionInfo
	// contains filtered or unexported fields
}

func (*Blog) Flags added in v0.5.0

func (cmd *Blog) Flags(stderr io.Writer) (*flag.FlagSet, error)

func (*Blog) Main added in v0.5.0

func (cmd *Blog) Main(ctx context.Context, pwd string, args []string) error

func (*Blog) WithPlugins added in v0.5.0

func (cmd *Blog) WithPlugins(fn plugins.FeederFn) error

type Commander

type Commander = cleo.Commander

type Encode

type Encode struct {
	cleo.Cmd

	File      string        // optional file name to preview
	Timeout   time.Duration // default: 5s
	Parser    *hype.Parser  // If nil, a default parser is used.
	ParseOnly bool          // if true, only parse the file and exit
	// contains filtered or unexported fields
}

func (*Encode) Flags

func (cmd *Encode) Flags() (*flag.FlagSet, error)

func (*Encode) Main

func (cmd *Encode) Main(ctx context.Context, pwd string, args []string) error

func (*Encode) SetParser

func (cmd *Encode) SetParser(p *hype.Parser) error

type Env

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

func (*Env) Getenv

func (e *Env) Getenv(key string) string

func (*Env) Setenv

func (e *Env) Setenv(key string, value string)

type Export

type Export struct {
	cleo.Cmd

	// a folder containing all chapters of a book, for example
	File    string        // optional file name to preview
	OutPath OutPath       // path to a file to write the output on success; default: nil
	Timeout time.Duration // default: 30s
	Parser  *hype.Parser  // If nil, a default parser is used.
	Verbose bool          // default: false
	Format  string        // default:markdown

	Theme      string // theme name for HTML export; default: "github"
	CustomCSS  string // path to custom CSS file
	NoCSS      bool   // output raw HTML without styling
	ListThemes bool   // list available themes and exit

	CheckLinks  bool          // enable link reachability checking
	LinkTimeout time.Duration // per-link check timeout
	LinkExclude string        // comma-separated URL patterns to exclude
	LinkRate    float64       // requests per second per host
	// contains filtered or unexported fields
}

func (*Export) Flags

func (cmd *Export) Flags(stderr io.Writer) (*flag.FlagSet, error)

func (*Export) Main

func (cmd *Export) Main(ctx context.Context, pwd string, args []string) error

func (*Export) ScopedPlugins

func (cmd *Export) ScopedPlugins() plugins.Plugins

func (*Export) SetParser

func (cmd *Export) SetParser(p *hype.Parser) error

func (*Export) WithPlugins

func (cmd *Export) WithPlugins(fn plugins.FeederFn) error

type Marked

type Marked struct {
	cleo.Cmd

	// a folder containing all chapters of a book, for example
	ContextPath string
	File        string        // optional file name to preview
	Timeout     time.Duration // default: 5s
	Parser      *hype.Parser  // If nil, a default parser is used.
	ParseOnly   bool          // if true, only parse the file and exit
	Section     int           // default: 1
	Verbose     bool          // default: false
	// contains filtered or unexported fields
}

func (*Marked) Flags

func (cmd *Marked) Flags() (*flag.FlagSet, error)

func (*Marked) Main

func (cmd *Marked) Main(ctx context.Context, pwd string, args []string) error

func (*Marked) ScopedPlugins

func (cmd *Marked) ScopedPlugins() plugins.Plugins

func (*Marked) SetParser

func (cmd *Marked) SetParser(p *hype.Parser) error

func (*Marked) WithPlugins

func (cmd *Marked) WithPlugins(fn plugins.FeederFn) error

type OutPath

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

func (*OutPath) Exists

func (o *OutPath) Exists() bool

func (*OutPath) Set

func (o *OutPath) Set(path string) error

func (*OutPath) String

func (o *OutPath) String() string

func (*OutPath) Value

func (o *OutPath) Value() string

type ParserCommander

type ParserCommander interface {
	cleo.Commander
	SetParser(p *hype.Parser) error
}

type Part

type Part binding.Part

func (Part) Children

func (p Part) Children() hype.Nodes

func (Part) String

func (p Part) String() string

type Preview added in v0.6.0

type Preview struct {
	cleo.Cmd

	File          string
	Port          int
	WatchDirs     stringSlice
	Extensions    string
	IncludeGlobs  stringSlice
	ExcludeGlobs  stringSlice
	DebounceDelay time.Duration
	Verbose       bool
	OpenBrowser   bool
	Theme         string
	CustomCSS     string
	ListThemes    bool
	Timeout       time.Duration
	Info          VersionInfo

	Parser *hype.Parser
	// contains filtered or unexported fields
}

func (*Preview) Flags added in v0.6.0

func (cmd *Preview) Flags(stderr io.Writer) (*flag.FlagSet, error)

func (*Preview) Main added in v0.6.0

func (cmd *Preview) Main(ctx context.Context, pwd string, args []string) error

func (*Preview) ScopedPlugins added in v0.6.0

func (cmd *Preview) ScopedPlugins() plugins.Plugins

func (*Preview) SetParser added in v0.6.0

func (cmd *Preview) SetParser(p *hype.Parser) error

func (*Preview) WithPlugins added in v0.6.0

func (cmd *Preview) WithPlugins(fn plugins.FeederFn) error

type Slides

type Slides struct {
	cleo.Cmd

	// Env to be used by the app
	// If nil, os.Getenv will be used.
	*Env

	// Web app to be used by the app
	slides.App

	Parser *hype.Parser

	// Server to be used by the app
	// If nil, a default server will be created.
	Server *http.Server

	// Port to listen on. Defaults to 3000.
	Port int
	// contains filtered or unexported fields
}

func (*Slides) Describe

func (a *Slides) Describe() string

func (*Slides) Getenv

func (a *Slides) Getenv(key string) (s string)

func (*Slides) Main

func (a *Slides) Main(ctx context.Context, pwd string, args []string) error

func (*Slides) Print

func (a *Slides) Print(w io.Writer) error

func (*Slides) SetIO

func (a *Slides) SetIO(oi iox.IO)

type TOC

type TOC struct {
	cleo.Cmd
}

func (*TOC) Main

func (cmd *TOC) Main(ctx context.Context, pwd string, args []string) error

type VSCode

type VSCode struct {
	cleo.Cmd

	Timeout time.Duration
	Host    string
	Parser  *hype.Parser // If nil, a default parser is used.
	// contains filtered or unexported fields
}

func (*VSCode) Flags

func (cmd *VSCode) Flags() (*flag.FlagSet, error)

func (*VSCode) Main

func (cmd *VSCode) Main(ctx context.Context, pwd string, args []string) error

type Validate added in v0.8.0

type Validate struct {
	cleo.Cmd

	File    string
	Timeout time.Duration
	Parser  *hype.Parser
	Verbose bool
	Exec    bool
	Format  string
	// contains filtered or unexported fields
}

func (*Validate) Flags added in v0.8.0

func (cmd *Validate) Flags(stderr io.Writer) (*flag.FlagSet, error)

func (*Validate) Main added in v0.8.0

func (cmd *Validate) Main(ctx context.Context, pwd string, args []string) error

func (*Validate) SetParser added in v0.8.0

func (cmd *Validate) SetParser(p *hype.Parser) error

type Version added in v0.6.0

type Version struct {
	cleo.Cmd

	Info VersionInfo
}

func (*Version) Main added in v0.6.0

func (cmd *Version) Main(ctx context.Context, pwd string, args []string) error

type VersionInfo added in v0.6.0

type VersionInfo struct {
	Version string
	Commit  string
	Date    string
}

func (VersionInfo) String added in v0.6.0

func (v VersionInfo) String() string

Jump to

Keyboard shortcuts

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