mirror of https://github.com/tidwall/tile38.git
typo in command docs
This commit is contained in:
parent
08e1d39818
commit
6561fcec30
|
@ -9,7 +9,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"name": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "FIELD",
|
"command": "FIELD",
|
||||||
|
|
|
@ -14,6 +14,7 @@ const (
|
||||||
yellow = "\x1b[33m"
|
yellow = "\x1b[33m"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Command represents a Tile38 command.
|
||||||
type Command struct {
|
type Command struct {
|
||||||
Name string `json:"-"`
|
Name string `json:"-"`
|
||||||
Summary string `json:"summary"`
|
Summary string `json:"summary"`
|
||||||
|
@ -24,6 +25,7 @@ type Command struct {
|
||||||
DevOnly bool `json:"dev"`
|
DevOnly bool `json:"dev"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String returns a string representation of the command.
|
||||||
func (c Command) String() string {
|
func (c Command) String() string {
|
||||||
var s = c.Name
|
var s = c.Name
|
||||||
for _, arg := range c.Arguments {
|
for _, arg := range c.Arguments {
|
||||||
|
@ -32,6 +34,7 @@ func (c Command) String() string {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TermOutput returns a string representation of the command suitable for displaying in a terminal.
|
||||||
func (c Command) TermOutput(indent string) string {
|
func (c Command) TermOutput(indent string) string {
|
||||||
line := c.String()
|
line := c.String()
|
||||||
var line1 string
|
var line1 string
|
||||||
|
@ -45,11 +48,13 @@ func (c Command) TermOutput(indent string) string {
|
||||||
return indent + line1 + "\n" + indent + line2 + "\n" //+ indent + line3 + "\n"
|
return indent + line1 + "\n" + indent + line2 + "\n" //+ indent + line3 + "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnumArg represents a enum arguments.
|
||||||
type EnumArg struct {
|
type EnumArg struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Arguments []Argument `json:"arguments"`
|
Arguments []Argument `json:"arguments"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String returns a string representation of an EnumArg.
|
||||||
func (a EnumArg) String() string {
|
func (a EnumArg) String() string {
|
||||||
var s = a.Name
|
var s = a.Name
|
||||||
for _, arg := range a.Arguments {
|
for _, arg := range a.Arguments {
|
||||||
|
@ -58,6 +63,7 @@ func (a EnumArg) String() string {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Argument represents a command argument.
|
||||||
type Argument struct {
|
type Argument struct {
|
||||||
Command string `json:"command"`
|
Command string `json:"command"`
|
||||||
NameAny interface{} `json:"name"`
|
NameAny interface{} `json:"name"`
|
||||||
|
@ -69,6 +75,7 @@ type Argument struct {
|
||||||
EnumArgs []EnumArg `json:"enumargs"`
|
EnumArgs []EnumArg `json:"enumargs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String returns a string representation of an Argument.
|
||||||
func (a Argument) String() string {
|
func (a Argument) String() string {
|
||||||
var s string
|
var s string
|
||||||
if a.Command != "" {
|
if a.Command != "" {
|
||||||
|
@ -126,6 +133,7 @@ func parseAnyStringArray(any interface{}) []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NameTypes returns the types and names of an argument as separate arrays.
|
||||||
func (a Argument) NameTypes() (names, types []string) {
|
func (a Argument) NameTypes() (names, types []string) {
|
||||||
names = parseAnyStringArray(a.NameAny)
|
names = parseAnyStringArray(a.NameAny)
|
||||||
types = parseAnyStringArray(a.TypeAny)
|
types = parseAnyStringArray(a.TypeAny)
|
||||||
|
@ -139,6 +147,7 @@ func (a Argument) NameTypes() (names, types []string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Commands is a map of all of the commands.
|
||||||
var Commands = func() map[string]Command {
|
var Commands = func() map[string]Command {
|
||||||
var commands map[string]Command
|
var commands map[string]Command
|
||||||
if err := json.Unmarshal([]byte(commandsJSON), &commands); err != nil {
|
if err := json.Unmarshal([]byte(commandsJSON), &commands); err != nil {
|
||||||
|
@ -162,7 +171,7 @@ var commandsJSON = `{
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"name": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "FIELD",
|
"command": "FIELD",
|
||||||
|
|
Loading…
Reference in New Issue