Documentation
¶
Index ¶
- Constants
- type OakCommand
- func (oc *OakCommand) DumpTree(tree *sitter.Tree)
- func (oc *OakCommand) DumpTreeToWriter(tree *sitter.Tree, source []byte, w io.Writer, format tree_sitter.DumpFormat, ...) error
- func (oc *OakCommand) GetLanguage() (*sitter.Language, error)
- func (oc *OakCommand) GetResultsByFile(ctx context.Context, fileNames []string) (map[string]tree_sitter.QueryResults, error)
- func (oc *OakCommand) Parse(ctx context.Context, oldTree *sitter.Tree, code []byte) (*sitter.Tree, error)
- func (oc *OakCommand) PrintQueries(w io.Writer) error
- func (oc *OakCommand) Render(results tree_sitter.QueryResults) (string, error)
- func (oc *OakCommand) RenderQueries(parsedValues *values.Values) error
- func (oc *OakCommand) RenderWithTemplate(results tree_sitter.QueryResults, tmpl *template.Template) (string, error)
- func (oc *OakCommand) RenderWithTemplateFile(results tree_sitter.QueryResults, file string) (string, error)
- func (oc *OakCommand) ResultsToJSON(results tree_sitter.QueryResults, f io.Writer) error
- func (oc *OakCommand) ResultsToYAML(results tree_sitter.QueryResults, f io.Writer) error
- type OakCommandDescription
- type OakCommandLoader
- func (o *OakCommandLoader) IsFileSupported(f fs.FS, fileName string) bool
- func (o *OakCommandLoader) LoadCommandAliasFromYAML(s io.Reader, options ...alias.Option) ([]*alias.CommandAlias, error)
- func (o *OakCommandLoader) LoadCommands(f fs.FS, entryName string, options []cmds.CommandDescriptionOption, ...) ([]cmds.Command, error)
- type OakCommandOption
- type OakGlazeCommand
- type OakGlazedCommandLoader
- func (o *OakGlazedCommandLoader) IsFileSupported(f fs.FS, fileName string) bool
- func (o *OakGlazedCommandLoader) LoadCommandAliasFromYAML(s io.Reader, options ...alias.Option) ([]*alias.CommandAlias, error)
- func (o *OakGlazedCommandLoader) LoadCommands(f fs.FS, entryName string, options []cmds.CommandDescriptionOption, ...) ([]cmds.Command, error)
- type OakParameterLayer
- type OakSettings
- type OakWriterCommand
- type RunSettings
Constants ¶
const OakSlug = "oak"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OakCommand ¶
type OakCommand struct {
Language string `yaml:"language,omitempty"`
Queries []tree_sitter.SitterQuery `yaml:"queries"`
Template string `yaml:"template"`
SitterLanguage *sitter.Language
*cmds.CommandDescription
}
func (*OakCommand) DumpTree ¶
func (oc *OakCommand) DumpTree(tree *sitter.Tree)
DumpTree prints the tree out to the console.
By default, it uses the legacy text format:
source_file [0-29]
function_declaration [0-29]
func [0-4]
name: identifier [5-6]
parameters: parameter_list [6-29]
( [6-7]
parameter_declaration [7-18]
name: identifier [7-8]
, [8-9]
name: identifier [10-11]
, [11-12]
name: identifier [13-14]
type: type_identifier [15-18]
But it can also output in several other formats (text, xml, json, yaml) when using DumpTreeToWriter with a specific format.
func (*OakCommand) DumpTreeToWriter ¶
func (oc *OakCommand) DumpTreeToWriter(tree *sitter.Tree, source []byte, w io.Writer, format tree_sitter.DumpFormat, options tree_sitter.DumpOptions) error
DumpTreeToWriter outputs the tree to the provided writer using the specified format.
func (*OakCommand) GetLanguage ¶
func (oc *OakCommand) GetLanguage() (*sitter.Language, error)
func (*OakCommand) GetResultsByFile ¶
func (oc *OakCommand) GetResultsByFile( ctx context.Context, fileNames []string, ) ( map[string]tree_sitter.QueryResults, error)
GetResultsByFile is a helper function that parses the given fileNames and returns a map of results by fileName.
func (*OakCommand) Parse ¶
func (oc *OakCommand) Parse(ctx context.Context, oldTree *sitter.Tree, code []byte) (*sitter.Tree, error)
Parse parses the given code using the language set in the command and returns the resulting tree.
func (*OakCommand) PrintQueries ¶
func (oc *OakCommand) PrintQueries(w io.Writer) error
func (*OakCommand) Render ¶
func (oc *OakCommand) Render(results tree_sitter.QueryResults) (string, error)
func (*OakCommand) RenderQueries ¶
func (oc *OakCommand) RenderQueries(parsedValues *values.Values) error
RenderQueries replaces all the queries in the command with their "Rendered" (using go templates) version.
WARNING: This is destructive and should only be called once. NOTE(manuel, 2023-06-19) This is not a great API, but it will do for now.
func (*OakCommand) RenderWithTemplate ¶
func (oc *OakCommand) RenderWithTemplate(results tree_sitter.QueryResults, tmpl *template.Template) (string, error)
func (*OakCommand) RenderWithTemplateFile ¶
func (oc *OakCommand) RenderWithTemplateFile(results tree_sitter.QueryResults, file string) (string, error)
func (*OakCommand) ResultsToJSON ¶
func (oc *OakCommand) ResultsToJSON(results tree_sitter.QueryResults, f io.Writer) error
func (*OakCommand) ResultsToYAML ¶
func (oc *OakCommand) ResultsToYAML(results tree_sitter.QueryResults, f io.Writer) error
type OakCommandDescription ¶
type OakCommandDescription struct {
Language string `yaml:"language,omitempty"`
Queries []tree_sitter.SitterQuery `yaml:"queries"`
Template string `yaml:"template,omitempty"`
Name string `yaml:"name"`
Short string `yaml:"short"`
Long string `yaml:"long,omitempty"`
Layout []*layout.Section `yaml:"layout,omitempty"`
Flags []*fields.Definition `yaml:"flags,omitempty"`
Layers []schema.Section `yaml:"-"`
Parents []string `yaml:",omitempty"`
Source string `yaml:",omitempty"`
}
type OakCommandLoader ¶
type OakCommandLoader struct {
}
func (*OakCommandLoader) IsFileSupported ¶
func (o *OakCommandLoader) IsFileSupported(f fs.FS, fileName string) bool
func (*OakCommandLoader) LoadCommandAliasFromYAML ¶
func (o *OakCommandLoader) LoadCommandAliasFromYAML( s io.Reader, options ...alias.Option, ) ([]*alias.CommandAlias, error)
func (*OakCommandLoader) LoadCommands ¶
type OakCommandOption ¶
type OakCommandOption func(*OakCommand)
func WithLanguage ¶
func WithLanguage(lang string) OakCommandOption
func WithQueries ¶
func WithQueries(queries ...tree_sitter.SitterQuery) OakCommandOption
func WithSitterLanguage ¶
func WithSitterLanguage(lang *sitter.Language) OakCommandOption
func WithTemplate ¶
func WithTemplate(template string) OakCommandOption
type OakGlazeCommand ¶
type OakGlazeCommand struct {
*OakCommand
}
func NewOakGlazedCommand ¶
func NewOakGlazedCommand(d *cmds.CommandDescription, options ...OakCommandOption) *OakGlazeCommand
func (*OakGlazeCommand) RunIntoGlazeProcessor ¶
func (oc *OakGlazeCommand) RunIntoGlazeProcessor( ctx context.Context, parsedValues *values.Values, gp middlewares.Processor, ) error
type OakGlazedCommandLoader ¶
type OakGlazedCommandLoader struct{}
func (*OakGlazedCommandLoader) IsFileSupported ¶
func (o *OakGlazedCommandLoader) IsFileSupported(f fs.FS, fileName string) bool
func (*OakGlazedCommandLoader) LoadCommandAliasFromYAML ¶
func (o *OakGlazedCommandLoader) LoadCommandAliasFromYAML( s io.Reader, options ...alias.Option, ) ([]*alias.CommandAlias, error)
func (*OakGlazedCommandLoader) LoadCommands ¶
type OakParameterLayer ¶
type OakParameterLayer struct {
*schema.SectionImpl `yaml:",inline"`
}
func NewOakParameterLayer ¶
func NewOakParameterLayer() (*OakParameterLayer, error)
type OakSettings ¶
type OakWriterCommand ¶
type OakWriterCommand struct {
*OakCommand
}
func NewOakWriterCommand ¶
func NewOakWriterCommand(d *cmds.CommandDescription, options ...OakCommandOption) *OakWriterCommand
func (*OakWriterCommand) RunIntoWriter ¶
type RunSettings ¶
type RunSettings struct {
Sources []string `glazed:"sources"`
}