oldhandler

package
v0.0.0-...-a4b7a9a Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

Original: Nested Command(s) with Arguments

This is the original prototype work done to demonstrate how to combine the flag (or pflag) packages as part of an internal CLI processing engine. This work is superseded by the work(s) in its parent directory.

(original README.md) below:

This example attempts to use the flag (or pflag) package in combination with arguments that represent commands and sub-commands to process flags at each level of the sub-command.

Structure of initial command line:

rootCmd -rootArg1 -rootArg2 subCmd -subArg1 ... subSubCmd -subSubArg1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdHandlerMap = make(HandlerMap)
View Source
var RootHandlerMap = make(HandlerMap)

Functions

func CmdHandler

func CmdHandler(args []string) (any, error)

func HandleCommand

func HandleCommand(handlerMap HandlerMap, args []string) (any, error)

HandleCommand processes args with the assumption that the first argument is a non-flag and is the command. HandleCommand is intended to be used recursively.

func RootHandler

func RootHandler(args []string) (string, error)

func SubCmdHandler

func SubCmdHandler(args []string) (any, error)

Types

type Handler

type Handler struct {
	Command string
	Handler func(args []string) (any, error)
}

type HandlerMap

type HandlerMap map[string]Handler

Jump to

Keyboard shortcuts

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