cmd

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 29 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

View Source
var COBRA_COMMAND_HELP_TEMPLATE string
View Source
var COBRA_COMMAND_SHORT_HELP_TEMPLATE string
View Source
var COBRA_COMMAND_USAGE_TEMPLATE string

COBRA_COMMAND_USAGE_TEMPLATE - template used by the glazed library help cobra command. This template has been adapted from the cobra usage command template.

Original: https://github.com/spf13/cobra

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

2022-12-03 - Manuel Odendahl - Augmented template with sections 2022-12-04 - Manuel Odendahl - Significantly reworked to support markdown sections

Functions

func AddExportCommand added in v1.2.4

func AddExportCommand(helpCmd *cobra.Command, hs *help.HelpSystem) error

AddExportCommand wires the export command into the help subcommand tree.

func MustRunUI

func MustRunUI(helpSystem *help.HelpSystem)

MustRunUI runs the UI and exits on error

func NewCobraHelpCommand

func NewCobraHelpCommand(hs *help.HelpSystem) *cobra.Command

NewCobraHelpCommand uses the InitDefaultHelpCommand code from cobra. This code is lifted from cobra and modified to accommodate help sections

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

2022-12-03 - Manuel Odendahl - Added support for help sections 2022-12-04 - Manuel Odendahl - Significantly reworked to support markdown sections 2025-07-10 - Manuel Odendahl - Added support for UI mode

func RunUI

func RunUI(helpSystem *help.HelpSystem) error

RunUI starts the interactive help UI

func RunUIWithOutput

func RunUIWithOutput(helpSystem *help.HelpSystem) (*model.Section, error)

RunUIWithOutput starts the interactive help UI and returns the selected section

func SetHelpWriter added in v0.7.1

func SetHelpWriter(w io.Writer)

SetHelpWriter configures the writer used for Glazed-generated Cobra help output. When unset, help content is written to the command's Stdout.

func SetupCobraRootCommand

func SetupCobraRootCommand(hs *help.HelpSystem, cmd *cobra.Command)

Types

type ExportCommand added in v1.2.4

type ExportCommand struct {
	*cmds.CommandDescription
	// contains filtered or unexported fields
}

ExportCommand exports help sections as structured data or to disk.

func NewExportCommand added in v1.2.4

func NewExportCommand(hs *help.HelpSystem) (*ExportCommand, error)

NewExportCommand creates a new export command.

func (*ExportCommand) Run added in v1.2.4

func (c *ExportCommand) Run(ctx context.Context, parsedValues *values.Values) error

Run executes the export command.

type ExportSettings added in v1.2.4

type ExportSettings struct {
	Type        string `glazed:"type"`
	Topic       string `glazed:"topic"`
	Command     string `glazed:"command"`
	Flag        string `glazed:"flag"`
	Slug        string `glazed:"slug"`
	WithContent bool   `glazed:"with-content"`
	Format      string `glazed:"format"`
	OutputPath  string `glazed:"output-path"`
	FlattenDirs bool   `glazed:"flatten-dirs"`
}

ExportSettings holds parsed flag values for the export command.

type HelpFunc

type HelpFunc = func(c *cobra.Command, args []string)

type UIFunc

type UIFunc = func(hs *help.HelpSystem) error

type UsageFunc

type UsageFunc = func(c *cobra.Command) error

Jump to

Keyboard shortcuts

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