Exemple #1
0
func (m *Mode) defineMode(name, desc string) (*Mode, error) {
	s := &Mode{
		Name: name,
		Desc: desc,
	}
	if err := m.subModes.Add(name, s); err != nil {
		return nil, ErrorDuplicatedMode
	}
	s.options = newOptions()
	s.subModes = omap.New()
	return s, nil
}
Exemple #2
0
package args

import (
	"os"

	"github.com/koron/gelatin/omap"
)

// Root is root mode.
var Root = &Mode{
	Name:     "(global)",
	Selected: true,
	options:  newOptions(),
	subModes: omap.New(),
}

// Parse aguments.
func Parse() error {
	return Root.Parse(os.Args[1:]...)
}