CMLine

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package CMLine provides a structure and functions for handling console command flags.

Package CMLine provides a structure and functions for handling console command flags.

Package CMLine provides a structure and functions for handling console command flags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandInfoOption added in v0.2.7

type CommandInfoOption func(*ConsoleCommandInfo) error

CommandInfoOption is a function type that modifies ConsoleCommandInfo.

Parameters:

  • command: The ConsoleCommandInfo to modify.

Returns:

  • error: An error if the modification fails.

func WithCallback added in v0.2.7

func WithCallback(callback func(map[string]any) (any, error)) CommandInfoOption

WithCallback is a CommandInfoOption that sets the callback for a ConsoleCommandInfo. If the provided callback is nil, it returns an error of type *ErrInvalidParameter.

Parameters:

  • callback: The function to call when the command is used.

Returns:

  • CommandInfoOption: A CommandInfoOption that sets the callback for a ConsoleCommandInfo.

func WithCommandDescription added in v0.2.8

func WithCommandDescription(description ...string) CommandInfoOption

WithCommandDescription is a CommandInfoOption that sets the description for a ConsoleCommandInfo. It splits each line of the description by newline characters.

Parameters:

  • description: The description to set.

Returns:

  • CommandInfoOption: A CommandInfoOption that sets the description for a ConsoleCommandInfo.

func WithFlag added in v0.2.7

func WithFlag(name string, callback func(...string) (any, error), options ...FlagInfoOption) CommandInfoOption

WithFlag is a CommandInfoOption that adds a new flag to a ConsoleCommandInfo. It creates a new ConsoleFlagInfo with the provided name and callback, and applies the provided options to it. If the flag name is empty or the callback is nil, it returns an error of type *ErrInvalidParameter.

Parameters:

  • name: The name of the flag.
  • callback: The function to call when the flag is used.
  • options: The options to apply to the flag.

Returns:

  • CommandInfoOption: A CommandInfoOption that adds a new flag to a ConsoleCommandInfo.

type ConsoleBuilder added in v0.2.16

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

ConsoleBuilder represents a builder for a command line interface.

func (*ConsoleBuilder) AddCommand added in v0.2.16

func (b *ConsoleBuilder) AddCommand(commandName string, options ...CommandInfoOption) error

AddCommand is a method of ConsoleBuilder that adds a new command to a ConsoleBuilder.

Parameters:

  • commandName: The name of the command.
  • options: The options to apply to the command.

Returns:

  • error: An error if the command cannot be added.

func (*ConsoleBuilder) AppendParagraph added in v0.2.16

func (b *ConsoleBuilder) AppendParagraph(contents ...string)

AppendParagraph is a method of ConsoleBuilder that appends a paragraph to the description of a ConsoleBuilder.

Parameters:

  • contents: The contents of the paragraph to append.

func (*ConsoleBuilder) Build added in v0.2.16

func (b *ConsoleBuilder) Build() *consolePanel

Build is a method of ConsoleBuilder that builds a CMLine from a ConsoleBuilder.

Returns:

  • *CMLine: A CMLine built from the ConsoleBuilder.

func (*ConsoleBuilder) Reset added in v0.2.16

func (b *ConsoleBuilder) Reset()

Reset is a method of ConsoleBuilder that resets a ConsoleBuilder.

func (*ConsoleBuilder) SetExecutableName added in v0.2.16

func (b *ConsoleBuilder) SetExecutableName(name string)

SetExecutableName is a method of ConsoleBuilder that sets the executable name for a ConsoleBuilder.

Parameters:

  • name: The name of the executable.

type ConsoleCommandInfo

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

ConsoleCommandInfo represents a console command.

func (*ConsoleCommandInfo) FString added in v0.2.3

func (cci *ConsoleCommandInfo) FString(indentLevel int) string

FString generates a formatted string representation of a ConsoleCommandInfo. It includes the command name, description, usage information for each flag, and the list of flags and their details.

Parameters:

  • indentLevel: The level of indentation to use. Sign is ignored.

Returns:

  • string: A string representing the ConsoleCommandInfo.

type ConsoleFlagInfo

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

ConsoleFlagInfo represents a flag for a console command.

func (*ConsoleFlagInfo) FString added in v0.2.3

func (cfi *ConsoleFlagInfo) FString(indentLevel int) string

FString generates a formatted string representation of a ConsoleFlagInfo, including the flag name, arguments, description, and whether it is required.

Parameters:

  • indentLevel: The level of indentation to use. Sign is ignored.

Returns:

  • string: A string representing the ConsoleFlagInfo.

type FlagInfoOption added in v0.2.7

type FlagInfoOption func(*ConsoleFlagInfo)

FlagInfoOption is a function type that modifies ConsoleFlagInfo.

Parameters:

  • ConsoleFlagInfo: The ConsoleFlagInfo to modify.

func WithArgs added in v0.2.7

func WithArgs(args ...string) FlagInfoOption

WithArgs is a FlagInfoOption that sets the arguments for a ConsoleFlagInfo. It trims the space from each argument and ignores empty arguments.

Parameters:

  • args: The arguments to set.

Returns:

  • FlagInfoOption: A FlagInfoOption that sets the arguments for a ConsoleFlagInfo.

func WithFlagDescription added in v0.2.8

func WithFlagDescription(description ...string) FlagInfoOption

WithFlagDescription is a FlagInfoOption that sets the description for a ConsoleFlagInfo. It splits each line of the description by newline characters.

Parameters:

  • description: The description to set.

Returns:

  • FlagInfoOption: A FlagInfoOption that sets the description for a ConsoleFlagInfo.

func WithRequired added in v0.2.7

func WithRequired(required bool) FlagInfoOption

WithRequired is a FlagInfoOption that sets whether a ConsoleFlagInfo is required.

Parameters:

  • required: Whether the flag is required.

Returns:

  • FlagInfoOption: A FlagInfoOption that sets whether a ConsoleFlagInfo is required.

Jump to

Keyboard shortcuts

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