optparser

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package optparser provides the logic for parsing flags for any given command. It also verifies any required option(s).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCommandOptions

func ParseCommandOptions(headline string, definitions OptionDefinitions,
	words []string) (map[string][]string, []string, error)

ParseCommandOptions behaves either as ReadGlobalOptions or as ParseCommandOptions. At present, there is no difference in behavior between the two.

Types

type OptionDefinition

type OptionDefinition struct {
	Synopsis  string
	Arguments []string

	Required bool
	// contains filtered or unexported fields
}

OptionDefinition holds the definition of one option.

The length of the Arguments slice tells how many arguments the option takes. The names are used when printing options in the usage message.

The stringVal and boolVal fields are for internal use only.

When the need arises for options of numeric or other non-string types, a field for the type of argument value should be added.

type OptionDefinitions

type OptionDefinitions map[string]*OptionDefinition // must be pointer

OptionDefinitions holds the definitions of multiple options.

Jump to

Keyboard shortcuts

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