func JSON() string {
	s := make(map[string]interface{})
	s["PackageVersion"] = Version
	s["Main"] = Main.Name
	s["Commands"] = Visible()
	return ConvertToJSON(s)
}
JSON returns a JSON representation of the state of the cmd package including
the main command and all subcommands from the internal index. This can be
useful when providing documentation in a structured data format that can be
easily shared and rendered in different ways. The json builtin simply calls
this and prints it. Empty values are always omitted. (See
Command.MarshalJSON() as well.)
package cmdtab
import (
	"context"
	"log"
	"os"
	"os/signal"
	"strings"
	"syscall"
)
var _Index = map[string]*Command{}
func Index() map[string]Command {
	copy := make(map[string]Command, len(_Index))
	for k, v := range _Index {
		copy[k] = *v
	}
	return copy
}
func Visible() map[string]*Command {
	vis := make(map[string]*Command)
	for k, v := range _Index {
		if !v.Hidden() {
			vis[k] = v
		}
	}
	return vis
}
func Hidden() map[string]*Command {
	vis := make(map[string]*Command)
	for k, v := range _Index {
		if v.Hidden() {
			vis[k] = v
		}
	}
	return vis
}
var CompLine string
func init() {
	CompLine = os.Getenv("COMP_LINE")
}
var Args = os.Args[1:]
func Call(name string, args []string) error {
	defer TrapPanic()
	command, has := _Index[name]
	if !has {
		return Unimplemented(name)
	}
	return command.Call(args)
}
var FixCompLine bool = true
func Complete() {
	if !FixCompLine {
		Main.Complete(CompLine)
		return
	}
	i := strings.Index(CompLine, " ")
	if i < 0 {
		Main.Complete(Main.Name)
	} else {
		Main.Complete(Main.Name + CompLine[i:])
	}
}
var Main *Command
func Execute(name string) {
	defer TrapPanic()
	command, has := _Index[name]
	if !has {
		ExitUnimplemented(name)
	}
	Main = command
	if !OmitAllBuiltins {
		for _, name := range builtins {
			if OmitBuiltins && name[0:1] == "_" {
				continue
			}
			Main.Add(name)
		}
	}
	if CompLine != "" {
		Complete()
		Exit()
	}
	err := command.Call(Args)
	if err != nil {
		ExitError(err)
	}
	Exit()
}
func ExitExec(xnargs ...string) error {
	return syscall.Exec(xnargs[0], xnargs, os.Environ())
}
func Has(name string) bool {
	_, has := _Index[name]
	return has
}
func New(name string, subcmds ...string) *Command {
	c := new(Command)
	c.Name = name
	c.Other = map[string]Stringer{}
	c.subcommands = []string{}
	if len(subcmds) > 0 {
		c.Add(subcmds...)
	}
	c.Usage = func() string { return c.defaultUsage() }
	_Index[name] = c
	return c
}
const Version = `v0.1.0`