commentv1

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseGoFile

func ParseGoFile(fset *token.FileSet, filename, importPath string, file io.Reader, cmdTree *CommandsTree) error

func ParseGoFiles

func ParseGoFiles(fsys fs.FS, root string) (*model.DataModel, error)

ParseGoFiles parses the Go files in the provided filesystem to build the command model. It expects a go.mod file at the root of the filesystem (or root directory).

func ParseSubCommandComments

func ParseSubCommandComments(text string) (cmdName string, subCommandSequence []string, description string, extendedHelp string, params map[string]ParsedParam, ok bool)

Types

type CommandTree

type CommandTree struct {
	CommandName string
	*SubCommandTree
	FunctionName       string
	CommandPackageName string
	DefinitionFile     string
	DocStart           token.Pos
	DocEnd             token.Pos
	Parameters         []*model.FunctionParameter
	ReturnsError       bool
	ReturnCount        int
	Description        string
	ExtendedHelp       string
}

type CommandsTree

type CommandsTree struct {
	Commands    map[string]*CommandTree
	PackagePath string
}

func (*CommandsTree) Insert

func (cst *CommandsTree) Insert(importPath, packageName, cmdName string, subcommandSequence []string, s *model.SubCommand)

type CommentParser

type CommentParser struct{}

func (*CommentParser) Parse

func (p *CommentParser) Parse(fsys fs.FS, root string, options *parsers.ParseOptions) (*model.DataModel, error)

type ParsedParam

type ParsedParam struct {
	Flags              []string
	Default            string
	Description        string
	IsPositional       bool
	PositionalArgIndex int
	IsVarArg           bool
	VarArgMin          int
	VarArgMax          int
}

type SubCommandTree

type SubCommandTree struct {
	SubCommands map[string]*SubCommandTree
	*model.SubCommand
}

func NewSubCommandTree

func NewSubCommandTree(subCommand *model.SubCommand) *SubCommandTree

func (*SubCommandTree) Insert

func (sct *SubCommandTree) Insert(importPath, packageName string, sequence []string, s *model.SubCommand)

Jump to

Keyboard shortcuts

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