help

package
v0.7.14 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 22 Imported by: 69

Documentation

Index

Constants

View Source
const (
	SectionGeneralTopic = model.SectionGeneralTopic
	SectionExample      = model.SectionExample
	SectionApplication  = model.SectionApplication
	SectionTutorial     = model.SectionTutorial
)

Variables

View Source
var HELP_LIST_TEMPLATE string
View Source
var HELP_LONG_SECTION_TEMPLATE string
View Source
var HELP_SHORT_SECTION_TEMPLATE string
View Source
var HELP_SHORT_TOPIC_TEMPLATE string
View Source
var HELP_TOPIC_TEMPLATE string
View Source
var SectionTypeFromString = model.SectionTypeFromString

Re-export functions from model package

Functions

func ExampleStoreUsage added in v0.5.53

func ExampleStoreUsage()

ExampleStoreUsage demonstrates how to use the new store-based query functionality

func RenderToMarkdown

func RenderToMarkdown(t *template.Template, data interface{}, output io.Writer) (string, error)

Types

type HelpError

type HelpError int
const (
	ErrSectionNotFound HelpError = iota
)

func (HelpError) Error

func (e HelpError) Error() string

type HelpPage

type HelpPage struct {
	DefaultGeneralTopics []*Section
	OtherGeneralTopics   []*Section
	// this is just the concatenation of default and others
	AllGeneralTopics []*Section

	DefaultExamples []*Section
	OtherExamples   []*Section
	AllExamples     []*Section

	DefaultApplications []*Section
	OtherApplications   []*Section
	AllApplications     []*Section

	DefaultTutorials []*Section
	OtherTutorials   []*Section
	AllTutorials     []*Section
}

HelpPage contains all the sections related to a command

func NewHelpPage

func NewHelpPage(sections []*Section) *HelpPage

type HelpSystem

type HelpSystem struct {
	Store *store.Store // Store backend
}

func NewHelpSystem

func NewHelpSystem() *HelpSystem

func NewHelpSystemWithStore added in v0.5.53

func NewHelpSystemWithStore(st *store.Store) *HelpSystem

NewHelpSystemWithStore creates a HelpSystem with store backend support

func (*HelpSystem) AddSection

func (hs *HelpSystem) AddSection(section *Section)

func (*HelpSystem) ComputeRenderData

func (hs *HelpSystem) ComputeRenderData(userQuery *SectionQuery) (map[string]interface{}, bool)

func (*HelpSystem) GetSectionWithSlug

func (hs *HelpSystem) GetSectionWithSlug(slug string) (*Section, error)

func (*HelpSystem) GetTopLevelHelpPage

func (hs *HelpSystem) GetTopLevelHelpPage() *HelpPage

func (*HelpSystem) LoadSectionsFromFS added in v0.2.4

func (hs *HelpSystem) LoadSectionsFromFS(f fs.FS, dir string) error

func (*HelpSystem) PrintQueryDebug added in v0.5.53

func (hs *HelpSystem) PrintQueryDebug(queryDSL string, printQuery, printSQL bool) error

PrintQueryDebug prints debug information about a query

func (*HelpSystem) QuerySections added in v0.5.53

func (hs *HelpSystem) QuerySections(query string) ([]*Section, error)

QuerySections performs a DSL query on the current help system with boolean logic support

func (*HelpSystem) RenderTopicHelp

func (hs *HelpSystem) RenderTopicHelp(
	topicSection *Section,
	options *RenderOptions) (string, error)

func (*HelpSystem) RenderTopicHelpWithWriter added in v0.7.1

func (hs *HelpSystem) RenderTopicHelpWithWriter(
	topicSection *Section,
	options *RenderOptions,
	output io.Writer,
) (string, error)

RenderTopicHelpWithWriter renders a topic's help content using the provided writer to detect terminal characteristics when applying Glamour styles.

type RenderOptions

type RenderOptions struct {
	Query                 *SectionQuery
	ShowAllSections       bool
	ShowShortTopic        bool
	HelpCommand           string
	LongHelp              bool
	ListSections          bool
	OnlyTopLevel          bool
	ShowDocumentationList bool
}

type Section

type Section struct {
	*model.Section
	HelpSystem *HelpSystem
}

Section is a structure describing an actual documentation section.

This can describe:

  • a general topic: think of this as an entry in a book
  • an example: a way to run a certain command
  • an application: a concrete use case for running a command. This can potentially use additional external tools, multiple commands, etc. While it is nice to keep these self-contained, it is not required.
  • a tutorial: a step-by-step guide to running a command.

Run `glaze help help-system` for more information.

func LoadSectionFromMarkdown

func LoadSectionFromMarkdown(markdownBytes []byte) (*Section, error)

func (*Section) DefaultApplications

func (s *Section) DefaultApplications() []*Section

func (*Section) DefaultExamples

func (s *Section) DefaultExamples() []*Section

func (*Section) DefaultGeneralTopic

func (s *Section) DefaultGeneralTopic() []*Section

func (*Section) DefaultTutorials

func (s *Section) DefaultTutorials() []*Section

func (*Section) IsForCommand

func (s *Section) IsForCommand(command string) bool

func (*Section) IsForFlag

func (s *Section) IsForFlag(flag string) bool

func (*Section) IsForTopic

func (s *Section) IsForTopic(topic string) bool

func (*Section) OtherApplications

func (s *Section) OtherApplications() []*Section

func (*Section) OtherExamples

func (s *Section) OtherExamples() []*Section

func (*Section) OtherTutorials

func (s *Section) OtherTutorials() []*Section

type SectionQuery

type SectionQuery struct {
	OnlyShownByDefault    bool
	OnlyNotShownByDefault bool
	OnlyTopLevel          bool

	// only these types will be returned
	Types map[SectionType]bool

	// if any of these is set, and they match each of the Only types,
	// the section will be return
	Topics   []string
	Flags    []string
	Commands []string
	Slugs    []string

	// this will return any section as long as it matches the Only strings
	All bool

	SearchedCommand string
	SearchedSlug    string

	// a section will be returned only if it matches all
	// of the following criteria
	OnlyTopics   []string
	OnlyFlags    []string
	OnlyCommands []string

	// We often need to filter sections that have already been shown
	WithoutSections []*Section
}

SectionQuery represents a query to get different types of sections.

This is used for example by the `help` command line function to render out the help sections for individual commands.

It can however also be used on its own.

func NewSectionQuery

func NewSectionQuery() *SectionQuery

func (*SectionQuery) Clone

func (s *SectionQuery) Clone() *SectionQuery

func (*SectionQuery) DontReturnApplications

func (s *SectionQuery) DontReturnApplications() *SectionQuery

func (*SectionQuery) DontReturnExamples

func (s *SectionQuery) DontReturnExamples() *SectionQuery

func (*SectionQuery) DontReturnTopics

func (s *SectionQuery) DontReturnTopics() *SectionQuery

func (*SectionQuery) DontReturnTutorials

func (s *SectionQuery) DontReturnTutorials() *SectionQuery

func (*SectionQuery) FilterSections

func (s *SectionQuery) FilterSections(sections ...*Section) *SectionQuery

func (*SectionQuery) FindSections

func (s *SectionQuery) FindSections(ctx context.Context, st *store.Store) ([]*Section, error)

FindSections queries sections using the store backend

func (*SectionQuery) GetOnlyQueryAsString

func (s *SectionQuery) GetOnlyQueryAsString() string

func (*SectionQuery) GetRequestedTypesAsString

func (s *SectionQuery) GetRequestedTypesAsString() string

func (*SectionQuery) HasOnlyQueries

func (s *SectionQuery) HasOnlyQueries() bool

func (*SectionQuery) HasRestrictedReturnTypes

func (s *SectionQuery) HasRestrictedReturnTypes() bool

func (*SectionQuery) IsOnlyTopLevel

func (s *SectionQuery) IsOnlyTopLevel() bool

func (*SectionQuery) ResetOnlyQueries

func (s *SectionQuery) ResetOnlyQueries() *SectionQuery

func (*SectionQuery) ReturnAllTypes

func (s *SectionQuery) ReturnAllTypes() *SectionQuery

func (*SectionQuery) ReturnAnyOfCommands

func (s *SectionQuery) ReturnAnyOfCommands(commands ...string) *SectionQuery

func (*SectionQuery) ReturnAnyOfFlags

func (s *SectionQuery) ReturnAnyOfFlags(flags ...string) *SectionQuery

func (*SectionQuery) ReturnAnyOfSlugs

func (s *SectionQuery) ReturnAnyOfSlugs(slugs ...string) *SectionQuery

func (*SectionQuery) ReturnAnyOfTopics

func (s *SectionQuery) ReturnAnyOfTopics(topics ...string) *SectionQuery

func (*SectionQuery) ReturnApplications

func (s *SectionQuery) ReturnApplications() *SectionQuery

func (*SectionQuery) ReturnExamples

func (s *SectionQuery) ReturnExamples() *SectionQuery

func (*SectionQuery) ReturnOnlyCommands

func (s *SectionQuery) ReturnOnlyCommands(commands ...string) *SectionQuery

func (*SectionQuery) ReturnOnlyFlags

func (s *SectionQuery) ReturnOnlyFlags(flags ...string) *SectionQuery

func (*SectionQuery) ReturnOnlyNotShownByDefault

func (s *SectionQuery) ReturnOnlyNotShownByDefault() *SectionQuery

func (*SectionQuery) ReturnOnlyShownByDefault

func (s *SectionQuery) ReturnOnlyShownByDefault() *SectionQuery

func (*SectionQuery) ReturnOnlyTopLevel

func (s *SectionQuery) ReturnOnlyTopLevel() *SectionQuery

func (*SectionQuery) ReturnOnlyTopics

func (s *SectionQuery) ReturnOnlyTopics(topics ...string) *SectionQuery

func (*SectionQuery) ReturnTopics

func (s *SectionQuery) ReturnTopics() *SectionQuery

func (*SectionQuery) ReturnTutorials

func (s *SectionQuery) ReturnTutorials() *SectionQuery

func (*SectionQuery) SearchForCommand

func (s *SectionQuery) SearchForCommand(command string) *SectionQuery

func (*SectionQuery) SearchForSlug

func (s *SectionQuery) SearchForSlug(slug string) *SectionQuery

type SectionType

type SectionType = model.SectionType

Re-export types from model package for backward compatibility

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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