cmds

command
v0.0.0-...-56cfde8 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT, MIT Imports: 2 Imported by: 0

README

cmds example

<tmpl,code=go:cat cmds.go>

package main

import (
	"fmt"

	"github.com/jpillora/opts"
)

type FooConfig struct {
	Ping string
	Pong string
}

//config
type Config struct {
	Cmd string `type:"cmdname"`
	//command (external struct)
	Foo FooConfig
	//command (inline struct)
	Bar struct {
		Zip string
		Zap string
	}
}

func main() {

	c := Config{}

	opts.Parse(&c)

	fmt.Println(c.Cmd)
	fmt.Println(c.Bar.Zip)
	fmt.Println(c.Bar.Zap)
}
``` $ cmds bar --zip hello --zap world ``` ``` plain bar hello world ``` ``` $ cmds --help ``` ``` plain

Usage: cmds [options]

Options: --help, -h

Commands: • foo • bar

</tmpl>

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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