id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
152,900
k-sone/critbitgo
critbit.go
Get
func (t *Trie) Get(key []byte) (value interface{}, ok bool) { if n := t.search(key); n.external != nil && bytes.Equal(n.external.key, key) { return n.external.value, true } return }
go
func (t *Trie) Get(key []byte) (value interface{}, ok bool) { if n := t.search(key); n.external != nil && bytes.Equal(n.external.key, key) { return n.external.value, true } return }
[ "func", "(", "t", "*", "Trie", ")", "Get", "(", "key", "[", "]", "byte", ")", "(", "value", "interface", "{", "}", ",", "ok", "bool", ")", "{", "if", "n", ":=", "t", ".", "search", "(", "key", ")", ";", "n", ".", "external", "!=", "nil", "&...
// get member. // if `key` is in Trie, `ok` is true.
[ "get", "member", ".", "if", "key", "is", "in", "Trie", "ok", "is", "true", "." ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/critbit.go#L103-L108
152,901
k-sone/critbitgo
critbit.go
Insert
func (t *Trie) Insert(key []byte, value interface{}) bool { return t.insert(key, value, false) }
go
func (t *Trie) Insert(key []byte, value interface{}) bool { return t.insert(key, value, false) }
[ "func", "(", "t", "*", "Trie", ")", "Insert", "(", "key", "[", "]", "byte", ",", "value", "interface", "{", "}", ")", "bool", "{", "return", "t", ".", "insert", "(", "key", ",", "value", ",", "false", ")", "\n", "}" ]
// insert into the tree. // if `key` is alredy in Trie, return false.
[ "insert", "into", "the", "tree", ".", "if", "key", "is", "alredy", "in", "Trie", "return", "false", "." ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/critbit.go#L168-L170
152,902
k-sone/critbitgo
critbit.go
Set
func (t *Trie) Set(key []byte, value interface{}) { t.insert(key, value, true) }
go
func (t *Trie) Set(key []byte, value interface{}) { t.insert(key, value, true) }
[ "func", "(", "t", "*", "Trie", ")", "Set", "(", "key", "[", "]", "byte", ",", "value", "interface", "{", "}", ")", "{", "t", ".", "insert", "(", "key", ",", "value", ",", "true", ")", "\n", "}" ]
// set into the tree.
[ "set", "into", "the", "tree", "." ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/critbit.go#L173-L175
152,903
k-sone/critbitgo
critbit.go
Delete
func (t *Trie) Delete(key []byte) (value interface{}, ok bool) { // an empty tree if t.size == 0 { return } var direction int var whereq *node // pointer to the grandparent var wherep *node = &t.root // finding the best candidate to delete for in := wherep.internal; in != nil; in = wherep.internal { direction = in.direction(key) whereq = wherep wherep = &in.child[direction] } // checking that we have the right element if !bytes.Equal(wherep.external.key, key) { return } value = wherep.external.value ok = true // removing the node if whereq == nil { wherep.external = nil } else { othern := whereq.internal.child[1-direction] whereq.internal = othern.internal whereq.external = othern.external } t.size -= 1 return }
go
func (t *Trie) Delete(key []byte) (value interface{}, ok bool) { // an empty tree if t.size == 0 { return } var direction int var whereq *node // pointer to the grandparent var wherep *node = &t.root // finding the best candidate to delete for in := wherep.internal; in != nil; in = wherep.internal { direction = in.direction(key) whereq = wherep wherep = &in.child[direction] } // checking that we have the right element if !bytes.Equal(wherep.external.key, key) { return } value = wherep.external.value ok = true // removing the node if whereq == nil { wherep.external = nil } else { othern := whereq.internal.child[1-direction] whereq.internal = othern.internal whereq.external = othern.external } t.size -= 1 return }
[ "func", "(", "t", "*", "Trie", ")", "Delete", "(", "key", "[", "]", "byte", ")", "(", "value", "interface", "{", "}", ",", "ok", "bool", ")", "{", "// an empty tree", "if", "t", ".", "size", "==", "0", "{", "return", "\n", "}", "\n\n", "var", "...
// deleting elements. // if `key` is in Trie, `ok` is true.
[ "deleting", "elements", ".", "if", "key", "is", "in", "Trie", "ok", "is", "true", "." ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/critbit.go#L179-L213
152,904
k-sone/critbitgo
critbit.go
Clear
func (t *Trie) Clear() { t.root.internal = nil t.root.external = nil t.size = 0 }
go
func (t *Trie) Clear() { t.root.internal = nil t.root.external = nil t.size = 0 }
[ "func", "(", "t", "*", "Trie", ")", "Clear", "(", ")", "{", "t", ".", "root", ".", "internal", "=", "nil", "\n", "t", ".", "root", ".", "external", "=", "nil", "\n", "t", ".", "size", "=", "0", "\n", "}" ]
// clearing a tree.
[ "clearing", "a", "tree", "." ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/critbit.go#L216-L220
152,905
k-sone/critbitgo
critbit.go
LongestPrefix
func (t *Trie) LongestPrefix(given []byte) (key []byte, value interface{}, ok bool) { // an empty tree if t.size == 0 { return } return longestPrefix(&t.root, given) }
go
func (t *Trie) LongestPrefix(given []byte) (key []byte, value interface{}, ok bool) { // an empty tree if t.size == 0 { return } return longestPrefix(&t.root, given) }
[ "func", "(", "t", "*", "Trie", ")", "LongestPrefix", "(", "given", "[", "]", "byte", ")", "(", "key", "[", "]", "byte", ",", "value", "interface", "{", "}", ",", "ok", "bool", ")", "{", "// an empty tree", "if", "t", ".", "size", "==", "0", "{", ...
// Search for the longest matching key from the beginning of the given key. // if `key` is in Trie, `ok` is true.
[ "Search", "for", "the", "longest", "matching", "key", "from", "the", "beginning", "of", "the", "given", "key", ".", "if", "key", "is", "in", "Trie", "ok", "is", "true", "." ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/critbit.go#L272-L278
152,906
jwaldrip/odin
cli/values/Uint64.go
NewUint64
func NewUint64(val uint64, p *uint64) *Uint64 { *p = val return (*Uint64)(p) }
go
func NewUint64(val uint64, p *uint64) *Uint64 { *p = val return (*Uint64)(p) }
[ "func", "NewUint64", "(", "val", "uint64", ",", "p", "*", "uint64", ")", "*", "Uint64", "{", "*", "p", "=", "val", "\n", "return", "(", "*", "Uint64", ")", "(", "p", ")", "\n", "}" ]
// NewUint64 returns a new uint64 value
[ "NewUint64", "returns", "a", "new", "uint64", "value" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/values/Uint64.go#L10-L13
152,907
jwaldrip/odin
cli/flag_access.go
Flag
func (cmd *CLI) Flag(name string) values.Value { flag := cmd.getFlag(name) value := cmd.flagValues[flag] return value }
go
func (cmd *CLI) Flag(name string) values.Value { flag := cmd.getFlag(name) value := cmd.flagValues[flag] return value }
[ "func", "(", "cmd", "*", "CLI", ")", "Flag", "(", "name", "string", ")", "values", ".", "Value", "{", "flag", ":=", "cmd", ".", "getFlag", "(", "name", ")", "\n", "value", ":=", "cmd", ".", "flagValues", "[", "flag", "]", "\n", "return", "value", ...
// Flag returns the Value interface to the value of the named flag, // panics if none exists.
[ "Flag", "returns", "the", "Value", "interface", "to", "the", "value", "of", "the", "named", "flag", "panics", "if", "none", "exists", "." ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_access.go#L11-L15
152,908
jwaldrip/odin
cli/flag_access.go
Flags
func (cmd *CLI) Flags() values.Map { flags := make(values.Map) for name := range cmd.inheritedFlags.Merge(cmd.flags) { flags[name] = cmd.Flag(name) } return flags }
go
func (cmd *CLI) Flags() values.Map { flags := make(values.Map) for name := range cmd.inheritedFlags.Merge(cmd.flags) { flags[name] = cmd.Flag(name) } return flags }
[ "func", "(", "cmd", "*", "CLI", ")", "Flags", "(", ")", "values", ".", "Map", "{", "flags", ":=", "make", "(", "values", ".", "Map", ")", "\n", "for", "name", ":=", "range", "cmd", ".", "inheritedFlags", ".", "Merge", "(", "cmd", ".", "flags", ")...
// Flags returns the flags as a map of strings with Values
[ "Flags", "returns", "the", "flags", "as", "a", "map", "of", "strings", "with", "Values" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_access.go#L18-L24
152,909
jwaldrip/odin
cli/param_definitions.go
DefineParams
func (cmd *CLI) DefineParams(names ...string) { var params []*Param for _, name := range names { param := &Param{Name: name} params = append(params, param) } cmd.params = params }
go
func (cmd *CLI) DefineParams(names ...string) { var params []*Param for _, name := range names { param := &Param{Name: name} params = append(params, param) } cmd.params = params }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineParams", "(", "names", "...", "string", ")", "{", "var", "params", "[", "]", "*", "Param", "\n", "for", "_", ",", "name", ":=", "range", "names", "{", "param", ":=", "&", "Param", "{", "Name", ":", "nam...
// DefineParams sets params names from strings
[ "DefineParams", "sets", "params", "names", "from", "strings" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/param_definitions.go#L4-L11
152,910
jwaldrip/odin
cli/FlagMap.go
Sort
func (fm flagMap) Sort() []*Flag { list := make(sort.StringSlice, len(fm)) i := 0 for _, f := range fm { list[i] = f.Name i++ } list.Sort() result := make([]*Flag, len(list)) for i, name := range list { result[i] = fm[name] } return result }
go
func (fm flagMap) Sort() []*Flag { list := make(sort.StringSlice, len(fm)) i := 0 for _, f := range fm { list[i] = f.Name i++ } list.Sort() result := make([]*Flag, len(list)) for i, name := range list { result[i] = fm[name] } return result }
[ "func", "(", "fm", "flagMap", ")", "Sort", "(", ")", "[", "]", "*", "Flag", "{", "list", ":=", "make", "(", "sort", ".", "StringSlice", ",", "len", "(", "fm", ")", ")", "\n", "i", ":=", "0", "\n", "for", "_", ",", "f", ":=", "range", "fm", ...
// Sort returns a sorted list of flags
[ "Sort", "returns", "a", "sorted", "list", "of", "flags" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/FlagMap.go#L32-L45
152,911
tomnomnom/xtermcolor
colors.go
intToRGBA
func intToRGBA(c uint32) color.RGBA { r := uint8((c >> 24) & 0xff) g := uint8((c >> 16) & 0xff) b := uint8((c >> 8) & 0xff) a := uint8(c & 0xff) return color.RGBA{r, g, b, a} }
go
func intToRGBA(c uint32) color.RGBA { r := uint8((c >> 24) & 0xff) g := uint8((c >> 16) & 0xff) b := uint8((c >> 8) & 0xff) a := uint8(c & 0xff) return color.RGBA{r, g, b, a} }
[ "func", "intToRGBA", "(", "c", "uint32", ")", "color", ".", "RGBA", "{", "r", ":=", "uint8", "(", "(", "c", ">>", "24", ")", "&", "0xff", ")", "\n", "g", ":=", "uint8", "(", "(", "c", ">>", "16", ")", "&", "0xff", ")", "\n", "b", ":=", "uin...
// Convert a 32 bit color to a color.RGBA
[ "Convert", "a", "32", "bit", "color", "to", "a", "color", ".", "RGBA" ]
b78803f00a7e8c5596d5ce64bb717a6a71464792
https://github.com/tomnomnom/xtermcolor/blob/b78803f00a7e8c5596d5ce64bb717a6a71464792/colors.go#L285-L291
152,912
jwaldrip/odin
cli/values/Float64.go
NewFloat64
func NewFloat64(val float64, p *float64) *Float64 { *p = val return (*Float64)(p) }
go
func NewFloat64(val float64, p *float64) *Float64 { *p = val return (*Float64)(p) }
[ "func", "NewFloat64", "(", "val", "float64", ",", "p", "*", "float64", ")", "*", "Float64", "{", "*", "p", "=", "val", "\n", "return", "(", "*", "Float64", ")", "(", "p", ")", "\n", "}" ]
// NewFloat64 returns a new float64 value
[ "NewFloat64", "returns", "a", "new", "float64", "value" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/values/Float64.go#L10-L13
152,913
jwaldrip/odin
cli/values/String.go
NewString
func NewString(val string, p *string) *String { *p = val return (*String)(p) }
go
func NewString(val string, p *string) *String { *p = val return (*String)(p) }
[ "func", "NewString", "(", "val", "string", ",", "p", "*", "string", ")", "*", "String", "{", "*", "p", "=", "val", "\n", "return", "(", "*", "String", ")", "(", "p", ")", "\n", "}" ]
// NewString returns a new string value
[ "NewString", "returns", "a", "new", "string", "value" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/values/String.go#L9-L12
152,914
jwaldrip/odin
cli/usage.go
FlagsUsageString
func (cmd *CLI) FlagsUsageString(title string) string { flagStrings := make(map[*Flag][]string) // init the usage strings slice for each flag for _, flag := range cmd.flags { flagStrings[flag] = []string{} } // alias keys for alias, flag := range cmd.aliases { flagStrings[flag] = append(flagStrings[flag], "-"+string(alias)) } // flag keys and values for _, flag := range cmd.flags { if _, boolflag := flag.value.(boolFlag); boolflag { flagStrings[flag] = append(flagStrings[flag], "--"+flag.Name) } else { flagStrings[flag] = append(flagStrings[flag], "--"+flag.Name+"="+flag.DefValue) } } // build the table tbl := NewSharedShellTable(&sep, &columnWidth) for flag, usages := range flagStrings { row := tbl.Row() row.Column(" ", strings.Join(usages, ", ")) row.Column(flag.Usage) } var usage string if cmd.parent != nil && cmd.parent.(*CLI).hasFlags() { parent := cmd.parent.(*CLI) parentUsage := parent.FlagsUsageString(fmt.Sprintf("Options for `%s`", parent.Name())) usage = fmt.Sprintf("%s%s", tbl.String(), parentUsage) } else { usage = tbl.String() } return fmt.Sprintf("\n\n%s:\n%s", title, usage) }
go
func (cmd *CLI) FlagsUsageString(title string) string { flagStrings := make(map[*Flag][]string) // init the usage strings slice for each flag for _, flag := range cmd.flags { flagStrings[flag] = []string{} } // alias keys for alias, flag := range cmd.aliases { flagStrings[flag] = append(flagStrings[flag], "-"+string(alias)) } // flag keys and values for _, flag := range cmd.flags { if _, boolflag := flag.value.(boolFlag); boolflag { flagStrings[flag] = append(flagStrings[flag], "--"+flag.Name) } else { flagStrings[flag] = append(flagStrings[flag], "--"+flag.Name+"="+flag.DefValue) } } // build the table tbl := NewSharedShellTable(&sep, &columnWidth) for flag, usages := range flagStrings { row := tbl.Row() row.Column(" ", strings.Join(usages, ", ")) row.Column(flag.Usage) } var usage string if cmd.parent != nil && cmd.parent.(*CLI).hasFlags() { parent := cmd.parent.(*CLI) parentUsage := parent.FlagsUsageString(fmt.Sprintf("Options for `%s`", parent.Name())) usage = fmt.Sprintf("%s%s", tbl.String(), parentUsage) } else { usage = tbl.String() } return fmt.Sprintf("\n\n%s:\n%s", title, usage) }
[ "func", "(", "cmd", "*", "CLI", ")", "FlagsUsageString", "(", "title", "string", ")", "string", "{", "flagStrings", ":=", "make", "(", "map", "[", "*", "Flag", "]", "[", "]", "string", ")", "\n\n", "// init the usage strings slice for each flag", "for", "_",...
// FlagsUsageString returns the flags usage as a string
[ "FlagsUsageString", "returns", "the", "flags", "usage", "as", "a", "string" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/usage.go#L18-L59
152,915
jwaldrip/odin
cli/usage.go
ParamsUsageString
func (cmd *CLI) ParamsUsageString() string { var formattednames []string for i := 0; i < len(cmd.params); i++ { param := cmd.params[i] formattednames = append(formattednames, fmt.Sprintf("<%s>", param.Name)) } return strings.Join(formattednames, " ") }
go
func (cmd *CLI) ParamsUsageString() string { var formattednames []string for i := 0; i < len(cmd.params); i++ { param := cmd.params[i] formattednames = append(formattednames, fmt.Sprintf("<%s>", param.Name)) } return strings.Join(formattednames, " ") }
[ "func", "(", "cmd", "*", "CLI", ")", "ParamsUsageString", "(", ")", "string", "{", "var", "formattednames", "[", "]", "string", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "cmd", ".", "params", ")", ";", "i", "++", "{", "param", ":=",...
// ParamsUsageString returns the params usage as a string
[ "ParamsUsageString", "returns", "the", "params", "usage", "as", "a", "string" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/usage.go#L62-L69
152,916
jwaldrip/odin
cli/usage.go
SubCommandsUsageString
func (cmd *CLI) SubCommandsUsageString(title string) string { tbl := NewSharedShellTable(&sep, &columnWidth) cmd.subCommands.Each(func(name string, command *SubCommand) { row := tbl.Row() row.Column(" ", command.Name()) aliases := decorateNameAliases(command.NameAliases()) desArray := []string{command.Description(), aliases} description := strings.Join(desArray, " ") row.Column(description) }) return fmt.Sprintf("\n\n%s:\n%s", title, tbl.String()) }
go
func (cmd *CLI) SubCommandsUsageString(title string) string { tbl := NewSharedShellTable(&sep, &columnWidth) cmd.subCommands.Each(func(name string, command *SubCommand) { row := tbl.Row() row.Column(" ", command.Name()) aliases := decorateNameAliases(command.NameAliases()) desArray := []string{command.Description(), aliases} description := strings.Join(desArray, " ") row.Column(description) }) return fmt.Sprintf("\n\n%s:\n%s", title, tbl.String()) }
[ "func", "(", "cmd", "*", "CLI", ")", "SubCommandsUsageString", "(", "title", "string", ")", "string", "{", "tbl", ":=", "NewSharedShellTable", "(", "&", "sep", ",", "&", "columnWidth", ")", "\n", "cmd", ".", "subCommands", ".", "Each", "(", "func", "(", ...
// SubCommandsUsageString is the usage string for sub commands
[ "SubCommandsUsageString", "is", "the", "usage", "string", "for", "sub", "commands" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/usage.go#L72-L83
152,917
jwaldrip/odin
cli/usage.go
Usage
func (cmd *CLI) Usage() { if cmd.usage == nil { cmd.usage = cmd.DefaultUsage } cmd.usage() }
go
func (cmd *CLI) Usage() { if cmd.usage == nil { cmd.usage = cmd.DefaultUsage } cmd.usage() }
[ "func", "(", "cmd", "*", "CLI", ")", "Usage", "(", ")", "{", "if", "cmd", ".", "usage", "==", "nil", "{", "cmd", ".", "usage", "=", "cmd", ".", "DefaultUsage", "\n", "}", "\n", "cmd", ".", "usage", "(", ")", "\n", "}" ]
// Usage calls the Usage method for the flag set
[ "Usage", "calls", "the", "Usage", "method", "for", "the", "flag", "set" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/usage.go#L99-L104
152,918
jwaldrip/odin
cli/usage.go
CommandUsageString
func (cmd *CLI) CommandUsageString() string { hasParams := len(cmd.params) > 0 hasParent := cmd.parent != nil var buff bytes.Buffer // Write the parent string if hasParent { buff.WriteString(cmd.parent.(*CLI).CommandUsageString()) } else { buff.WriteString(" ") } // Write the name with options buff.WriteString(fmt.Sprintf(" %s", cmd.Name())) if cmd.hasFlags() { buff.WriteString(" [options...]") } // Write Param Syntax if hasParams { buff.WriteString(fmt.Sprintf(" %s", cmd.ParamsUsageString())) } return buff.String() }
go
func (cmd *CLI) CommandUsageString() string { hasParams := len(cmd.params) > 0 hasParent := cmd.parent != nil var buff bytes.Buffer // Write the parent string if hasParent { buff.WriteString(cmd.parent.(*CLI).CommandUsageString()) } else { buff.WriteString(" ") } // Write the name with options buff.WriteString(fmt.Sprintf(" %s", cmd.Name())) if cmd.hasFlags() { buff.WriteString(" [options...]") } // Write Param Syntax if hasParams { buff.WriteString(fmt.Sprintf(" %s", cmd.ParamsUsageString())) } return buff.String() }
[ "func", "(", "cmd", "*", "CLI", ")", "CommandUsageString", "(", ")", "string", "{", "hasParams", ":=", "len", "(", "cmd", ".", "params", ")", ">", "0", "\n", "hasParent", ":=", "cmd", ".", "parent", "!=", "nil", "\n", "var", "buff", "bytes", ".", "...
// CommandUsageString returns the command and its accepted options and params
[ "CommandUsageString", "returns", "the", "command", "and", "its", "accepted", "options", "and", "params" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/usage.go#L107-L132
152,919
jwaldrip/odin
cli/usage.go
UsageString
func (cmd *CLI) UsageString() string { hasSubCommands := len(cmd.subCommands) > 0 hasDescription := len(cmd.description) > 0 hasLongDescription := len(cmd.longDescription) > 0 // Prefetch table to calculate the widths _ = cmd.SubCommandsUsageString("") _ = cmd.FlagsUsageString("") // Start the Buffer var buff bytes.Buffer buff.WriteString("Usage:\n") buff.WriteString(cmd.CommandUsageString()) // Write Sub Command Syntax if hasSubCommands { buff.WriteString(" <command> [arg...]") } if hasLongDescription { buff.WriteString(fmt.Sprintf("\n\n%s", cmd.LongDescription())) } else if hasDescription { buff.WriteString(fmt.Sprintf("\n\n%s", cmd.Description())) } // Write Options Syntax buff.WriteString(cmd.FlagsUsageString("Options")) // Write Sub Command List if hasSubCommands { buff.WriteString(cmd.SubCommandsUsageString("Commands")) } // Return buffer as string return buff.String() }
go
func (cmd *CLI) UsageString() string { hasSubCommands := len(cmd.subCommands) > 0 hasDescription := len(cmd.description) > 0 hasLongDescription := len(cmd.longDescription) > 0 // Prefetch table to calculate the widths _ = cmd.SubCommandsUsageString("") _ = cmd.FlagsUsageString("") // Start the Buffer var buff bytes.Buffer buff.WriteString("Usage:\n") buff.WriteString(cmd.CommandUsageString()) // Write Sub Command Syntax if hasSubCommands { buff.WriteString(" <command> [arg...]") } if hasLongDescription { buff.WriteString(fmt.Sprintf("\n\n%s", cmd.LongDescription())) } else if hasDescription { buff.WriteString(fmt.Sprintf("\n\n%s", cmd.Description())) } // Write Options Syntax buff.WriteString(cmd.FlagsUsageString("Options")) // Write Sub Command List if hasSubCommands { buff.WriteString(cmd.SubCommandsUsageString("Commands")) } // Return buffer as string return buff.String() }
[ "func", "(", "cmd", "*", "CLI", ")", "UsageString", "(", ")", "string", "{", "hasSubCommands", ":=", "len", "(", "cmd", ".", "subCommands", ")", ">", "0", "\n", "hasDescription", ":=", "len", "(", "cmd", ".", "description", ")", ">", "0", "\n", "hasL...
// UsageString returns the command usage as a string
[ "UsageString", "returns", "the", "command", "usage", "as", "a", "string" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/usage.go#L135-L171
152,920
jwaldrip/odin
cli/values/Int.go
NewInt
func NewInt(val int, p *int) *Int { *p = val return (*Int)(p) }
go
func NewInt(val int, p *int) *Int { *p = val return (*Int)(p) }
[ "func", "NewInt", "(", "val", "int", ",", "p", "*", "int", ")", "*", "Int", "{", "*", "p", "=", "val", "\n", "return", "(", "*", "Int", ")", "(", "p", ")", "\n", "}" ]
// NewInt returns a new integer value
[ "NewInt", "returns", "a", "new", "integer", "value" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/values/Int.go#L10-L13
152,921
jwaldrip/odin
cli/param_access.go
Param
func (cmd *CLI) Param(name string) values.Value { value, ok := cmd.Params()[name] if !ok { panic(fmt.Sprintf("param not defined %v", name)) } return value }
go
func (cmd *CLI) Param(name string) values.Value { value, ok := cmd.Params()[name] if !ok { panic(fmt.Sprintf("param not defined %v", name)) } return value }
[ "func", "(", "cmd", "*", "CLI", ")", "Param", "(", "name", "string", ")", "values", ".", "Value", "{", "value", ",", "ok", ":=", "cmd", ".", "Params", "(", ")", "[", "name", "]", "\n", "if", "!", "ok", "{", "panic", "(", "fmt", ".", "Sprintf", ...
// Param returns named param
[ "Param", "returns", "named", "param" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/param_access.go#L10-L16
152,922
jwaldrip/odin
cli/param_access.go
Params
func (cmd *CLI) Params() values.Map { params := make(values.Map) for param, value := range cmd.paramValues { params[param.Name] = value } return params }
go
func (cmd *CLI) Params() values.Map { params := make(values.Map) for param, value := range cmd.paramValues { params[param.Name] = value } return params }
[ "func", "(", "cmd", "*", "CLI", ")", "Params", "(", ")", "values", ".", "Map", "{", "params", ":=", "make", "(", "values", ".", "Map", ")", "\n", "for", "param", ",", "value", ":=", "range", "cmd", ".", "paramValues", "{", "params", "[", "param", ...
// Params returns the non-flag arguments.
[ "Params", "returns", "the", "non", "-", "flag", "arguments", "." ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/param_access.go#L19-L25
152,923
jwaldrip/odin
cli/output.go
ErrPrintf
func (cmd *CLI) ErrPrintf(format string, a ...interface{}) { fmt.Fprintf(cmd.StdErr(), format, a...) }
go
func (cmd *CLI) ErrPrintf(format string, a ...interface{}) { fmt.Fprintf(cmd.StdErr(), format, a...) }
[ "func", "(", "cmd", "*", "CLI", ")", "ErrPrintf", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "fmt", ".", "Fprintf", "(", "cmd", ".", "StdErr", "(", ")", ",", "format", ",", "a", "...", ")", "\n", "}" ]
// ErrPrintf does a fmt.Printf to the std err of the CLI
[ "ErrPrintf", "does", "a", "fmt", ".", "Printf", "to", "the", "std", "err", "of", "the", "CLI" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/output.go#L20-L22
152,924
jwaldrip/odin
cli/output.go
Mute
func (cmd *CLI) Mute() { var err error cmd.errOutput, err = os.Open(os.DevNull) cmd.stdOutput, err = os.Open(os.DevNull) exitIfError(err) }
go
func (cmd *CLI) Mute() { var err error cmd.errOutput, err = os.Open(os.DevNull) cmd.stdOutput, err = os.Open(os.DevNull) exitIfError(err) }
[ "func", "(", "cmd", "*", "CLI", ")", "Mute", "(", ")", "{", "var", "err", "error", "\n", "cmd", ".", "errOutput", ",", "err", "=", "os", ".", "Open", "(", "os", ".", "DevNull", ")", "\n", "cmd", ".", "stdOutput", ",", "err", "=", "os", ".", "...
// Mute mutes the output
[ "Mute", "mutes", "the", "output" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/output.go#L30-L35
152,925
jwaldrip/odin
cli/output.go
Printf
func (cmd *CLI) Printf(format string, a ...interface{}) { fmt.Fprintf(cmd.StdOut(), format, a...) }
go
func (cmd *CLI) Printf(format string, a ...interface{}) { fmt.Fprintf(cmd.StdOut(), format, a...) }
[ "func", "(", "cmd", "*", "CLI", ")", "Printf", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "fmt", ".", "Fprintf", "(", "cmd", ".", "StdOut", "(", ")", ",", "format", ",", "a", "...", ")", "\n", "}" ]
// Printf does a fmt.Printf to the std out of the CLI
[ "Printf", "does", "a", "fmt", ".", "Printf", "to", "the", "std", "out", "of", "the", "CLI" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/output.go#L43-L45
152,926
jwaldrip/odin
cli/output.go
StdOut
func (cmd *CLI) StdOut() io.Writer { if cmd.stdOutput == nil { cmd.stdOutput = os.Stdout } return cmd.stdOutput }
go
func (cmd *CLI) StdOut() io.Writer { if cmd.stdOutput == nil { cmd.stdOutput = os.Stdout } return cmd.stdOutput }
[ "func", "(", "cmd", "*", "CLI", ")", "StdOut", "(", ")", "io", ".", "Writer", "{", "if", "cmd", ".", "stdOutput", "==", "nil", "{", "cmd", ".", "stdOutput", "=", "os", ".", "Stdout", "\n", "}", "\n", "return", "cmd", ".", "stdOutput", "\n", "}" ]
// StdOut is the standard output for the command
[ "StdOut", "is", "the", "standard", "output", "for", "the", "command" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/output.go#L73-L78
152,927
jwaldrip/odin
cli/output.go
StdErr
func (cmd *CLI) StdErr() io.Writer { if cmd.errOutput == nil { cmd.errOutput = os.Stderr } return cmd.errOutput }
go
func (cmd *CLI) StdErr() io.Writer { if cmd.errOutput == nil { cmd.errOutput = os.Stderr } return cmd.errOutput }
[ "func", "(", "cmd", "*", "CLI", ")", "StdErr", "(", ")", "io", ".", "Writer", "{", "if", "cmd", ".", "errOutput", "==", "nil", "{", "cmd", ".", "errOutput", "=", "os", ".", "Stderr", "\n", "}", "\n", "return", "cmd", ".", "errOutput", "\n", "}" ]
// StdErr is the error output for the command
[ "StdErr", "is", "the", "error", "output", "for", "the", "command" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/output.go#L86-L91
152,928
k-sone/critbitgo
net.go
AddCIDR
func (n *Net) AddCIDR(s string, value interface{}) (err error) { var r *net.IPNet if _, r, err = net.ParseCIDR(s); err == nil { n.Add(r, value) } return }
go
func (n *Net) AddCIDR(s string, value interface{}) (err error) { var r *net.IPNet if _, r, err = net.ParseCIDR(s); err == nil { n.Add(r, value) } return }
[ "func", "(", "n", "*", "Net", ")", "AddCIDR", "(", "s", "string", ",", "value", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "var", "r", "*", "net", ".", "IPNet", "\n", "if", "_", ",", "r", ",", "err", "=", "net", ".", "ParseCID...
// Add a route. // If `s` is not CIDR notation, returns an error.
[ "Add", "a", "route", ".", "If", "s", "is", "not", "CIDR", "notation", "returns", "an", "error", "." ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/net.go#L29-L35
152,929
k-sone/critbitgo
net.go
DeleteCIDR
func (n *Net) DeleteCIDR(s string) (value interface{}, ok bool, err error) { var r *net.IPNet if _, r, err = net.ParseCIDR(s); err == nil { value, ok, err = n.Delete(r) } return }
go
func (n *Net) DeleteCIDR(s string) (value interface{}, ok bool, err error) { var r *net.IPNet if _, r, err = net.ParseCIDR(s); err == nil { value, ok, err = n.Delete(r) } return }
[ "func", "(", "n", "*", "Net", ")", "DeleteCIDR", "(", "s", "string", ")", "(", "value", "interface", "{", "}", ",", "ok", "bool", ",", "err", "error", ")", "{", "var", "r", "*", "net", ".", "IPNet", "\n", "if", "_", ",", "r", ",", "err", "=",...
// Delete a specific route. // If `s` is not CIDR notation or a route is not found, `ok` is false.
[ "Delete", "a", "specific", "route", ".", "If", "s", "is", "not", "CIDR", "notation", "or", "a", "route", "is", "not", "found", "ok", "is", "false", "." ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/net.go#L49-L55
152,930
k-sone/critbitgo
net.go
GetCIDR
func (n *Net) GetCIDR(s string) (value interface{}, ok bool, err error) { var r *net.IPNet if _, r, err = net.ParseCIDR(s); err == nil { value, ok, err = n.Get(r) } return }
go
func (n *Net) GetCIDR(s string) (value interface{}, ok bool, err error) { var r *net.IPNet if _, r, err = net.ParseCIDR(s); err == nil { value, ok, err = n.Get(r) } return }
[ "func", "(", "n", "*", "Net", ")", "GetCIDR", "(", "s", "string", ")", "(", "value", "interface", "{", "}", ",", "ok", "bool", ",", "err", "error", ")", "{", "var", "r", "*", "net", ".", "IPNet", "\n", "if", "_", ",", "r", ",", "err", "=", ...
// Get a specific route. // If `s` is not CIDR notation or a route is not found, `ok` is false.
[ "Get", "a", "specific", "route", ".", "If", "s", "is", "not", "CIDR", "notation", "or", "a", "route", "is", "not", "found", "ok", "is", "false", "." ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/net.go#L69-L75
152,931
k-sone/critbitgo
net.go
MatchCIDR
func (n *Net) MatchCIDR(s string) (route *net.IPNet, value interface{}, err error) { var r *net.IPNet if _, r, err = net.ParseCIDR(s); err == nil { route, value, err = n.Match(r) } return }
go
func (n *Net) MatchCIDR(s string) (route *net.IPNet, value interface{}, err error) { var r *net.IPNet if _, r, err = net.ParseCIDR(s); err == nil { route, value, err = n.Match(r) } return }
[ "func", "(", "n", "*", "Net", ")", "MatchCIDR", "(", "s", "string", ")", "(", "route", "*", "net", ".", "IPNet", ",", "value", "interface", "{", "}", ",", "err", "error", ")", "{", "var", "r", "*", "net", ".", "IPNet", "\n", "if", "_", ",", "...
// Return a specific route by using the longest prefix matching. // If `s` is not CIDR notation, or a route is not found, `route` is nil.
[ "Return", "a", "specific", "route", "by", "using", "the", "longest", "prefix", "matching", ".", "If", "s", "is", "not", "CIDR", "notation", "or", "a", "route", "is", "not", "found", "route", "is", "nil", "." ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/net.go#L92-L98
152,932
k-sone/critbitgo
net.go
ContainedIP
func (n *Net) ContainedIP(ip net.IP) (contained bool, err error) { k, _, err := n.matchIP(ip) contained = k != nil return }
go
func (n *Net) ContainedIP(ip net.IP) (contained bool, err error) { k, _, err := n.matchIP(ip) contained = k != nil return }
[ "func", "(", "n", "*", "Net", ")", "ContainedIP", "(", "ip", "net", ".", "IP", ")", "(", "contained", "bool", ",", "err", "error", ")", "{", "k", ",", "_", ",", "err", ":=", "n", ".", "matchIP", "(", "ip", ")", "\n", "contained", "=", "k", "!...
// Return a bool indicating whether a route would be found
[ "Return", "a", "bool", "indicating", "whether", "a", "route", "would", "be", "found" ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/net.go#L101-L105
152,933
k-sone/critbitgo
net.go
MatchIP
func (n *Net) MatchIP(ip net.IP) (route *net.IPNet, value interface{}, err error) { k, v, err := n.matchIP(ip) if k != nil { route = netKeyToIPNet(k) value = v } return }
go
func (n *Net) MatchIP(ip net.IP) (route *net.IPNet, value interface{}, err error) { k, v, err := n.matchIP(ip) if k != nil { route = netKeyToIPNet(k) value = v } return }
[ "func", "(", "n", "*", "Net", ")", "MatchIP", "(", "ip", "net", ".", "IP", ")", "(", "route", "*", "net", ".", "IPNet", ",", "value", "interface", "{", "}", ",", "err", "error", ")", "{", "k", ",", "v", ",", "err", ":=", "n", ".", "matchIP", ...
// Return a specific route by using the longest prefix matching. // If `ip` is invalid IP, or a route is not found, `route` is nil.
[ "Return", "a", "specific", "route", "by", "using", "the", "longest", "prefix", "matching", ".", "If", "ip", "is", "invalid", "IP", "or", "a", "route", "is", "not", "found", "route", "is", "nil", "." ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/net.go#L109-L116
152,934
jwaldrip/odin
cli/values/Duration.go
NewDuration
func NewDuration(val time.Duration, p *time.Duration) *Duration { *p = val return (*Duration)(p) }
go
func NewDuration(val time.Duration, p *time.Duration) *Duration { *p = val return (*Duration)(p) }
[ "func", "NewDuration", "(", "val", "time", ".", "Duration", ",", "p", "*", "time", ".", "Duration", ")", "*", "Duration", "{", "*", "p", "=", "val", "\n", "return", "(", "*", "Duration", ")", "(", "p", ")", "\n", "}" ]
// NewDuration returns a new time.Duration value
[ "NewDuration", "returns", "a", "new", "time", ".", "Duration", "value" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/values/Duration.go#L9-L12
152,935
jwaldrip/odin
cli/flag_parsing.go
defineHelp
func (cmd *CLI) defineHelp() { if _, ok := cmd.flags["help"]; !ok { cmd.DefineBoolFlag("help", false, "show help and exit") cmd.flagHelp = cmd.flags["help"] if _, ok := cmd.aliases['h']; !ok { cmd.AliasFlag('h', "help") } } }
go
func (cmd *CLI) defineHelp() { if _, ok := cmd.flags["help"]; !ok { cmd.DefineBoolFlag("help", false, "show help and exit") cmd.flagHelp = cmd.flags["help"] if _, ok := cmd.aliases['h']; !ok { cmd.AliasFlag('h', "help") } } }
[ "func", "(", "cmd", "*", "CLI", ")", "defineHelp", "(", ")", "{", "if", "_", ",", "ok", ":=", "cmd", ".", "flags", "[", "\"", "\"", "]", ";", "!", "ok", "{", "cmd", ".", "DefineBoolFlag", "(", "\"", "\"", ",", "false", ",", "\"", "\"", ")", ...
// defineHelp defines a help function and alias if they are not present
[ "defineHelp", "defines", "a", "help", "function", "and", "alias", "if", "they", "are", "not", "present" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_parsing.go#L10-L18
152,936
jwaldrip/odin
cli/flag_parsing.go
defineVersion
func (cmd *CLI) defineVersion() { if _, ok := cmd.flags["version"]; !ok && len(cmd.Version()) > 0 { cmd.DefineBoolFlag("version", false, "show version and exit") cmd.flagVersion = cmd.flags["version"] if _, ok := cmd.aliases['v']; !ok { cmd.AliasFlag('v', "version") } } }
go
func (cmd *CLI) defineVersion() { if _, ok := cmd.flags["version"]; !ok && len(cmd.Version()) > 0 { cmd.DefineBoolFlag("version", false, "show version and exit") cmd.flagVersion = cmd.flags["version"] if _, ok := cmd.aliases['v']; !ok { cmd.AliasFlag('v', "version") } } }
[ "func", "(", "cmd", "*", "CLI", ")", "defineVersion", "(", ")", "{", "if", "_", ",", "ok", ":=", "cmd", ".", "flags", "[", "\"", "\"", "]", ";", "!", "ok", "&&", "len", "(", "cmd", ".", "Version", "(", ")", ")", ">", "0", "{", "cmd", ".", ...
// defineVersion defines a version if one has been set
[ "defineVersion", "defines", "a", "version", "if", "one", "has", "been", "set" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_parsing.go#L21-L29
152,937
jwaldrip/odin
cli/flag_parsing.go
flagFromArg
func (cmd *CLI) flagFromArg(arg string) (bool, []*Flag) { var flags []*Flag // Do nothing if flags terminated if cmd.flagsTerminated { return false, flags } if arg[len(arg)-1] == '=' { cmd.errf("invalid flag format") } arg = strings.Split(arg, "=")[0] // Determine if we need to terminate flags isFlag := arg[0] == '-' areAliases := isFlag && arg[1] != '-' isTerminator := !areAliases && len(arg) == 2 if isTerminator { cmd.flagsTerminated = true return false, flags } // Determine if name or alias if areAliases { aliases := arg[1:] for _, c := range aliases { flag, ok := cmd.aliases[c] if !ok { cmd.errf("invalid alias: %v", string(c)) } flags = append(flags, flag) } } else { name := arg[2:] flag, ok := cmd.flags[name] if !ok { cmd.errf("invalid flag") } flags = append(flags, flag) } return areAliases, flags }
go
func (cmd *CLI) flagFromArg(arg string) (bool, []*Flag) { var flags []*Flag // Do nothing if flags terminated if cmd.flagsTerminated { return false, flags } if arg[len(arg)-1] == '=' { cmd.errf("invalid flag format") } arg = strings.Split(arg, "=")[0] // Determine if we need to terminate flags isFlag := arg[0] == '-' areAliases := isFlag && arg[1] != '-' isTerminator := !areAliases && len(arg) == 2 if isTerminator { cmd.flagsTerminated = true return false, flags } // Determine if name or alias if areAliases { aliases := arg[1:] for _, c := range aliases { flag, ok := cmd.aliases[c] if !ok { cmd.errf("invalid alias: %v", string(c)) } flags = append(flags, flag) } } else { name := arg[2:] flag, ok := cmd.flags[name] if !ok { cmd.errf("invalid flag") } flags = append(flags, flag) } return areAliases, flags }
[ "func", "(", "cmd", "*", "CLI", ")", "flagFromArg", "(", "arg", "string", ")", "(", "bool", ",", "[", "]", "*", "Flag", ")", "{", "var", "flags", "[", "]", "*", "Flag", "\n\n", "// Do nothing if flags terminated", "if", "cmd", ".", "flagsTerminated", "...
// flagFromArg determines the flags from an argument
[ "flagFromArg", "determines", "the", "flags", "from", "an", "argument" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_parsing.go#L32-L73
152,938
jwaldrip/odin
cli/flag_parsing.go
parseFlags
func (cmd *CLI) parseFlags(args []string) []string { cmd.defineHelp() cmd.defineVersion() cmd.initFlagValues() // Set all the flags to defaults before setting cmd.setFlagDefaults() // copy propogating flags cmd.copyPropogatingFlags() // Set inherited values cmd.setFlagValuesFromParent() var paramIndex int var nonFlags []string // Set each flag by its set value for { // Break if no arguments remain if len(args) == 0 { cmd.flagsTerminated = true break } arg := args[0] if arg[0] != '-' { // Parse Param if paramIndex == len(cmd.params) && len(cmd.subCommands) > 0 { break } nonFlags = append(nonFlags, arg) paramIndex++ args = args[1:] } else { // Parse Flags isAlias, flags := cmd.flagFromArg(arg) // Break if the flags have been terminated if cmd.flagsTerminated { // Remove the flag terminator if it exists if arg == "--" { args = args[1:] } break } // Set flag values if isAlias { args = cmd.setAliasValues(flags, args) } else { args = cmd.setFlagValue(flags[0], args) } } } // reposition the Args so that they may still be parsed args = append(nonFlags, args...) // return the remaining unused args return args }
go
func (cmd *CLI) parseFlags(args []string) []string { cmd.defineHelp() cmd.defineVersion() cmd.initFlagValues() // Set all the flags to defaults before setting cmd.setFlagDefaults() // copy propogating flags cmd.copyPropogatingFlags() // Set inherited values cmd.setFlagValuesFromParent() var paramIndex int var nonFlags []string // Set each flag by its set value for { // Break if no arguments remain if len(args) == 0 { cmd.flagsTerminated = true break } arg := args[0] if arg[0] != '-' { // Parse Param if paramIndex == len(cmd.params) && len(cmd.subCommands) > 0 { break } nonFlags = append(nonFlags, arg) paramIndex++ args = args[1:] } else { // Parse Flags isAlias, flags := cmd.flagFromArg(arg) // Break if the flags have been terminated if cmd.flagsTerminated { // Remove the flag terminator if it exists if arg == "--" { args = args[1:] } break } // Set flag values if isAlias { args = cmd.setAliasValues(flags, args) } else { args = cmd.setFlagValue(flags[0], args) } } } // reposition the Args so that they may still be parsed args = append(nonFlags, args...) // return the remaining unused args return args }
[ "func", "(", "cmd", "*", "CLI", ")", "parseFlags", "(", "args", "[", "]", "string", ")", "[", "]", "string", "{", "cmd", ".", "defineHelp", "(", ")", "\n", "cmd", ".", "defineVersion", "(", ")", "\n", "cmd", ".", "initFlagValues", "(", ")", "\n\n",...
// parse flag and param definitions from the argument list, returns any left // over arguments after flags have been parsed.
[ "parse", "flag", "and", "param", "definitions", "from", "the", "argument", "list", "returns", "any", "left", "over", "arguments", "after", "flags", "have", "been", "parsed", "." ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_parsing.go#L83-L145
152,939
jwaldrip/odin
cli/flag_parsing.go
setAliasValues
func (cmd *CLI) setAliasValues(flags []*Flag, args []string) []string { for i, flag := range flags { isLastFlag := i == len(flags)-1 if isLastFlag { args = cmd.setFlagValue(flag, args) } else { cmd.setFlagValue(flag, []string{}) } } return args }
go
func (cmd *CLI) setAliasValues(flags []*Flag, args []string) []string { for i, flag := range flags { isLastFlag := i == len(flags)-1 if isLastFlag { args = cmd.setFlagValue(flag, args) } else { cmd.setFlagValue(flag, []string{}) } } return args }
[ "func", "(", "cmd", "*", "CLI", ")", "setAliasValues", "(", "flags", "[", "]", "*", "Flag", ",", "args", "[", "]", "string", ")", "[", "]", "string", "{", "for", "i", ",", "flag", ":=", "range", "flags", "{", "isLastFlag", ":=", "i", "==", "len",...
// setAliasValues sets the values of flags from thier aliases
[ "setAliasValues", "sets", "the", "values", "of", "flags", "from", "thier", "aliases" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_parsing.go#L148-L158
152,940
jwaldrip/odin
cli/flag_parsing.go
setFlagDefaults
func (cmd *CLI) setFlagDefaults() { for _, flag := range cmd.flags { cmd.setFlag(flag, flag.DefValue) } }
go
func (cmd *CLI) setFlagDefaults() { for _, flag := range cmd.flags { cmd.setFlag(flag, flag.DefValue) } }
[ "func", "(", "cmd", "*", "CLI", ")", "setFlagDefaults", "(", ")", "{", "for", "_", ",", "flag", ":=", "range", "cmd", ".", "flags", "{", "cmd", ".", "setFlag", "(", "flag", ",", "flag", ".", "DefValue", ")", "\n", "}", "\n", "}" ]
// setFlagDefaults sets the default values of all flags
[ "setFlagDefaults", "sets", "the", "default", "values", "of", "all", "flags" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_parsing.go#L161-L165
152,941
jwaldrip/odin
cli/flag_parsing.go
setFlag
func (cmd *CLI) setFlag(flag *Flag, value string) error { _ = cmd.flags[flag.Name] // Verify the flag is a flag for f set err := flag.value.Set(value) if err != nil { return err } cmd.flagValues[flag] = flag.value return nil }
go
func (cmd *CLI) setFlag(flag *Flag, value string) error { _ = cmd.flags[flag.Name] // Verify the flag is a flag for f set err := flag.value.Set(value) if err != nil { return err } cmd.flagValues[flag] = flag.value return nil }
[ "func", "(", "cmd", "*", "CLI", ")", "setFlag", "(", "flag", "*", "Flag", ",", "value", "string", ")", "error", "{", "_", "=", "cmd", ".", "flags", "[", "flag", ".", "Name", "]", "// Verify the flag is a flag for f set", "\n", "err", ":=", "flag", ".",...
// setFlag sets the value of the named flag.
[ "setFlag", "sets", "the", "value", "of", "the", "named", "flag", "." ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_parsing.go#L168-L176
152,942
jwaldrip/odin
cli/flag_parsing.go
setFlagValue
func (cmd *CLI) setFlagValue(flag *Flag, args []string) []string { if flag == nil { flag = noFlag // Fix for when we continue on error } splitArgs := []string{} hasSetValue := false hasPosValue := false isBoolFlag := false if fv, ok := flag.value.(boolFlag); ok && fv.IsBoolValue() { isBoolFlag = true } if len(args) > 0 { splitArgs = strings.Split(args[0], "=") hasSetValue = len(splitArgs) >= 2 hasPosValue = len(args) >= 2 && args[1][0] != '-' } cutLen := 0 var err error if hasSetValue { err = cmd.setFlag(flag, splitArgs[1]) cutLen = 1 } else if isBoolFlag { cmd.setFlag(flag, "true") cutLen = 1 } else if hasPosValue { err = cmd.setFlag(flag, args[1]) cutLen = 2 } else { cmd.errf("flag \"--%v\" is missing a value", flag.Name) } cmd.handleErr(err) if len(args) > cutLen { return args[cutLen:] } return []string{} }
go
func (cmd *CLI) setFlagValue(flag *Flag, args []string) []string { if flag == nil { flag = noFlag // Fix for when we continue on error } splitArgs := []string{} hasSetValue := false hasPosValue := false isBoolFlag := false if fv, ok := flag.value.(boolFlag); ok && fv.IsBoolValue() { isBoolFlag = true } if len(args) > 0 { splitArgs = strings.Split(args[0], "=") hasSetValue = len(splitArgs) >= 2 hasPosValue = len(args) >= 2 && args[1][0] != '-' } cutLen := 0 var err error if hasSetValue { err = cmd.setFlag(flag, splitArgs[1]) cutLen = 1 } else if isBoolFlag { cmd.setFlag(flag, "true") cutLen = 1 } else if hasPosValue { err = cmd.setFlag(flag, args[1]) cutLen = 2 } else { cmd.errf("flag \"--%v\" is missing a value", flag.Name) } cmd.handleErr(err) if len(args) > cutLen { return args[cutLen:] } return []string{} }
[ "func", "(", "cmd", "*", "CLI", ")", "setFlagValue", "(", "flag", "*", "Flag", ",", "args", "[", "]", "string", ")", "[", "]", "string", "{", "if", "flag", "==", "nil", "{", "flag", "=", "noFlag", "// Fix for when we continue on error", "\n", "}", "\n"...
// setFlagValue sets the value of a given flag
[ "setFlagValue", "sets", "the", "value", "of", "a", "given", "flag" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_parsing.go#L179-L220
152,943
jwaldrip/odin
cli/SubCommand.go
NewSubCommand
func NewSubCommand(name string, desc string, fn func(Command), paramNames ...string) *SubCommand { var cmd SubCommand cmd.init(name, desc, fn, paramNames...) return &cmd }
go
func NewSubCommand(name string, desc string, fn func(Command), paramNames ...string) *SubCommand { var cmd SubCommand cmd.init(name, desc, fn, paramNames...) return &cmd }
[ "func", "NewSubCommand", "(", "name", "string", ",", "desc", "string", ",", "fn", "func", "(", "Command", ")", ",", "paramNames", "...", "string", ")", "*", "SubCommand", "{", "var", "cmd", "SubCommand", "\n", "cmd", ".", "init", "(", "name", ",", "des...
// NewSubCommand Create a new subcommand instance. It takes a name, desc, command // and params. If desc is equal to "none" or "hidden", this will not generate // documentation for this command.
[ "NewSubCommand", "Create", "a", "new", "subcommand", "instance", ".", "It", "takes", "a", "name", "desc", "command", "and", "params", ".", "If", "desc", "is", "equal", "to", "none", "or", "hidden", "this", "will", "not", "generate", "documentation", "for", ...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/SubCommand.go#L11-L15
152,944
jwaldrip/odin
cli/aliasName.go
AliasName
func (cmd *CLI) AliasName(alias, subCommand string) { if cmd.nameAliases == nil { cmd.nameAliases = make(map[string]string) } cmd.nameAliases[alias] = subCommand }
go
func (cmd *CLI) AliasName(alias, subCommand string) { if cmd.nameAliases == nil { cmd.nameAliases = make(map[string]string) } cmd.nameAliases[alias] = subCommand }
[ "func", "(", "cmd", "*", "CLI", ")", "AliasName", "(", "alias", ",", "subCommand", "string", ")", "{", "if", "cmd", ".", "nameAliases", "==", "nil", "{", "cmd", ".", "nameAliases", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "...
// AliasName allows you to call the subcommand by an alias
[ "AliasName", "allows", "you", "to", "call", "the", "subcommand", "by", "an", "alias" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/aliasName.go#L4-L9
152,945
jwaldrip/odin
cli/values/Int64.go
NewInt64
func NewInt64(val int64, p *int64) *Int64 { *p = val return (*Int64)(p) }
go
func NewInt64(val int64, p *int64) *Int64 { *p = val return (*Int64)(p) }
[ "func", "NewInt64", "(", "val", "int64", ",", "p", "*", "int64", ")", "*", "Int64", "{", "*", "p", "=", "val", "\n", "return", "(", "*", "Int64", ")", "(", "p", ")", "\n", "}" ]
// NewInt64 returns a new int64 value
[ "NewInt64", "returns", "a", "new", "int64", "value" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/values/Int64.go#L10-L13
152,946
jwaldrip/odin
cli/values/List.go
GetAll
func (v List) GetAll() []interface{} { var interfaces []interface{} for _, value := range v { interfaces = append(interfaces, value.Get()) } return interfaces }
go
func (v List) GetAll() []interface{} { var interfaces []interface{} for _, value := range v { interfaces = append(interfaces, value.Get()) } return interfaces }
[ "func", "(", "v", "List", ")", "GetAll", "(", ")", "[", "]", "interface", "{", "}", "{", "var", "interfaces", "[", "]", "interface", "{", "}", "\n", "for", "_", ",", "value", ":=", "range", "v", "{", "interfaces", "=", "append", "(", "interfaces", ...
// GetAll gets an interface for all values in the list
[ "GetAll", "gets", "an", "interface", "for", "all", "values", "in", "the", "list" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/values/List.go#L7-L13
152,947
jwaldrip/odin
cli/values/List.go
Strings
func (v List) Strings() []string { var strings []string for _, value := range v { strings = append(strings, value.String()) } return strings }
go
func (v List) Strings() []string { var strings []string for _, value := range v { strings = append(strings, value.String()) } return strings }
[ "func", "(", "v", "List", ")", "Strings", "(", ")", "[", "]", "string", "{", "var", "strings", "[", "]", "string", "\n", "for", "_", ",", "value", ":=", "range", "v", "{", "strings", "=", "append", "(", "strings", ",", "value", ".", "String", "("...
// Strings returns all the values as their strings
[ "Strings", "returns", "all", "the", "values", "as", "their", "strings" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/values/List.go#L16-L22
152,948
Scalingo/go-etcd-lock
lock/lockmock/gomock_lock.go
Release
func (m *MockLock) Release() error { ret := m.ctrl.Call(m, "Release") ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockLock) Release() error { ret := m.ctrl.Call(m, "Release") ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockLock", ")", "Release", "(", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return...
// Release mocks base method
[ "Release", "mocks", "base", "method" ]
fecab5a750cc9a7c7665e5f83943b4d40ae227c5
https://github.com/Scalingo/go-etcd-lock/blob/fecab5a750cc9a7c7665e5f83943b4d40ae227c5/lock/lockmock/gomock_lock.go#L36-L40
152,949
Scalingo/go-etcd-lock
lock/lockmock/gomock_lock.go
Release
func (mr *MockLockMockRecorder) Release() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Release", reflect.TypeOf((*MockLock)(nil).Release)) }
go
func (mr *MockLockMockRecorder) Release() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Release", reflect.TypeOf((*MockLock)(nil).Release)) }
[ "func", "(", "mr", "*", "MockLockMockRecorder", ")", "Release", "(", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf"...
// Release indicates an expected call of Release
[ "Release", "indicates", "an", "expected", "call", "of", "Release" ]
fecab5a750cc9a7c7665e5f83943b4d40ae227c5
https://github.com/Scalingo/go-etcd-lock/blob/fecab5a750cc9a7c7665e5f83943b4d40ae227c5/lock/lockmock/gomock_lock.go#L43-L45
152,950
jwaldrip/odin
cli/subCommandList.go
Each
func (l *subCommandList) Each(fn func(string, *SubCommand)) { for _, item := range *l { if item.command.Hidden() { continue } fn(item.name, item.command) } }
go
func (l *subCommandList) Each(fn func(string, *SubCommand)) { for _, item := range *l { if item.command.Hidden() { continue } fn(item.name, item.command) } }
[ "func", "(", "l", "*", "subCommandList", ")", "Each", "(", "fn", "func", "(", "string", ",", "*", "SubCommand", ")", ")", "{", "for", "_", ",", "item", ":=", "range", "*", "l", "{", "if", "item", ".", "command", ".", "Hidden", "(", ")", "{", "c...
// Each loops through each subcommand
[ "Each", "loops", "through", "each", "subcommand" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/subCommandList.go#L12-L19
152,951
jwaldrip/odin
cli/flag_definitions.go
AliasFlag
func (cmd *CLI) AliasFlag(alias rune, flagname string) { flag, ok := cmd.flags[flagname] if !ok { panic(fmt.Sprintf("flag not defined %v", flagname)) } if cmd.aliases == nil { cmd.aliases = make(map[rune]*Flag) } cmd.aliases[alias] = flag }
go
func (cmd *CLI) AliasFlag(alias rune, flagname string) { flag, ok := cmd.flags[flagname] if !ok { panic(fmt.Sprintf("flag not defined %v", flagname)) } if cmd.aliases == nil { cmd.aliases = make(map[rune]*Flag) } cmd.aliases[alias] = flag }
[ "func", "(", "cmd", "*", "CLI", ")", "AliasFlag", "(", "alias", "rune", ",", "flagname", "string", ")", "{", "flag", ",", "ok", ":=", "cmd", ".", "flags", "[", "flagname", "]", "\n", "if", "!", "ok", "{", "panic", "(", "fmt", ".", "Sprintf", "(",...
// AliasFlag creates an alias from a flag
[ "AliasFlag", "creates", "an", "alias", "from", "a", "flag" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L11-L20
152,952
jwaldrip/odin
cli/flag_definitions.go
DefineBoolFlag
func (cmd *CLI) DefineBoolFlag(name string, value bool, usage string) *bool { p := new(bool) cmd.DefineBoolFlagVar(p, name, value, usage) return p }
go
func (cmd *CLI) DefineBoolFlag(name string, value bool, usage string) *bool { p := new(bool) cmd.DefineBoolFlagVar(p, name, value, usage) return p }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineBoolFlag", "(", "name", "string", ",", "value", "bool", ",", "usage", "string", ")", "*", "bool", "{", "p", ":=", "new", "(", "bool", ")", "\n", "cmd", ".", "DefineBoolFlagVar", "(", "p", ",", "name", ","...
// DefineBoolFlag defines a bool flag with specified name, default value, and usage string. // The return value is the address of a bool variable that stores the value of the flag.
[ "DefineBoolFlag", "defines", "a", "bool", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "return", "value", "is", "the", "address", "of", "a", "bool", "variable", "that", "stores", "the", "value", "of", "the", ...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L24-L28
152,953
jwaldrip/odin
cli/flag_definitions.go
DefineBoolFlagVar
func (cmd *CLI) DefineBoolFlagVar(p *bool, name string, value bool, usage string) { cmd.DefineFlag(values.NewBool(value, p), name, usage) }
go
func (cmd *CLI) DefineBoolFlagVar(p *bool, name string, value bool, usage string) { cmd.DefineFlag(values.NewBool(value, p), name, usage) }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineBoolFlagVar", "(", "p", "*", "bool", ",", "name", "string", ",", "value", "bool", ",", "usage", "string", ")", "{", "cmd", ".", "DefineFlag", "(", "values", ".", "NewBool", "(", "value", ",", "p", ")", ",...
// DefineBoolFlagVar defines a bool flag with specified name, default value, and usage string. // The argument p points to a bool variable in which to store the value of the flag.
[ "DefineBoolFlagVar", "defines", "a", "bool", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "argument", "p", "points", "to", "a", "bool", "variable", "in", "which", "to", "store", "the", "value", "of", "the", ...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L32-L34
152,954
jwaldrip/odin
cli/flag_definitions.go
DefineDurationFlag
func (cmd *CLI) DefineDurationFlag(name string, value time.Duration, usage string) *time.Duration { p := new(time.Duration) cmd.DefineDurationFlagVar(p, name, value, usage) return p }
go
func (cmd *CLI) DefineDurationFlag(name string, value time.Duration, usage string) *time.Duration { p := new(time.Duration) cmd.DefineDurationFlagVar(p, name, value, usage) return p }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineDurationFlag", "(", "name", "string", ",", "value", "time", ".", "Duration", ",", "usage", "string", ")", "*", "time", ".", "Duration", "{", "p", ":=", "new", "(", "time", ".", "Duration", ")", "\n", "cmd",...
// DefineDurationFlag defines a time.Duration flag with specified name, default value, and usage string. // The return value is the address of a time.Duration variable that stores the value of the flag.
[ "DefineDurationFlag", "defines", "a", "time", ".", "Duration", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "return", "value", "is", "the", "address", "of", "a", "time", ".", "Duration", "variable", "that", "...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L38-L42
152,955
jwaldrip/odin
cli/flag_definitions.go
DefineDurationFlagVar
func (cmd *CLI) DefineDurationFlagVar(p *time.Duration, name string, value time.Duration, usage string) { cmd.DefineFlag(values.NewDuration(value, p), name, usage) }
go
func (cmd *CLI) DefineDurationFlagVar(p *time.Duration, name string, value time.Duration, usage string) { cmd.DefineFlag(values.NewDuration(value, p), name, usage) }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineDurationFlagVar", "(", "p", "*", "time", ".", "Duration", ",", "name", "string", ",", "value", "time", ".", "Duration", ",", "usage", "string", ")", "{", "cmd", ".", "DefineFlag", "(", "values", ".", "NewDura...
// DefineDurationFlagVar defines a time.Duration flag with specified name, default value, and usage string. // The argument p points to a time.Duration variable in which to store the value of the flag.
[ "DefineDurationFlagVar", "defines", "a", "time", ".", "Duration", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "argument", "p", "points", "to", "a", "time", ".", "Duration", "variable", "in", "which", "to", "...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L46-L48
152,956
jwaldrip/odin
cli/flag_definitions.go
DefineFloat64Flag
func (cmd *CLI) DefineFloat64Flag(name string, value float64, usage string) *float64 { p := new(float64) cmd.DefineFloat64FlagVar(p, name, value, usage) return p }
go
func (cmd *CLI) DefineFloat64Flag(name string, value float64, usage string) *float64 { p := new(float64) cmd.DefineFloat64FlagVar(p, name, value, usage) return p }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineFloat64Flag", "(", "name", "string", ",", "value", "float64", ",", "usage", "string", ")", "*", "float64", "{", "p", ":=", "new", "(", "float64", ")", "\n", "cmd", ".", "DefineFloat64FlagVar", "(", "p", ",", ...
// DefineFloat64Flag defines a float64 flag with specified name, default value, and usage string. // The return value is the address of a float64 variable that stores the value of the flag.
[ "DefineFloat64Flag", "defines", "a", "float64", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "return", "value", "is", "the", "address", "of", "a", "float64", "variable", "that", "stores", "the", "value", "of", ...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L52-L56
152,957
jwaldrip/odin
cli/flag_definitions.go
DefineFloat64FlagVar
func (cmd *CLI) DefineFloat64FlagVar(p *float64, name string, value float64, usage string) { cmd.DefineFlag(values.NewFloat64(value, p), name, usage) }
go
func (cmd *CLI) DefineFloat64FlagVar(p *float64, name string, value float64, usage string) { cmd.DefineFlag(values.NewFloat64(value, p), name, usage) }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineFloat64FlagVar", "(", "p", "*", "float64", ",", "name", "string", ",", "value", "float64", ",", "usage", "string", ")", "{", "cmd", ".", "DefineFlag", "(", "values", ".", "NewFloat64", "(", "value", ",", "p",...
// DefineFloat64FlagVar defines a float64 flag with specified name, default value, and usage string. // The argument p points to a float64 variable in which to store the value of the flag.
[ "DefineFloat64FlagVar", "defines", "a", "float64", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "argument", "p", "points", "to", "a", "float64", "variable", "in", "which", "to", "store", "the", "value", "of", ...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L60-L62
152,958
jwaldrip/odin
cli/flag_definitions.go
DefineInt64Flag
func (cmd *CLI) DefineInt64Flag(name string, value int64, usage string) *int64 { p := new(int64) cmd.DefineInt64FlagVar(p, name, value, usage) return p }
go
func (cmd *CLI) DefineInt64Flag(name string, value int64, usage string) *int64 { p := new(int64) cmd.DefineInt64FlagVar(p, name, value, usage) return p }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineInt64Flag", "(", "name", "string", ",", "value", "int64", ",", "usage", "string", ")", "*", "int64", "{", "p", ":=", "new", "(", "int64", ")", "\n", "cmd", ".", "DefineInt64FlagVar", "(", "p", ",", "name", ...
// DefineInt64Flag defines an int64 flag with specified name, default value, and usage string. // The return value is the address of an int64 variable that stores the value of the flag.
[ "DefineInt64Flag", "defines", "an", "int64", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "return", "value", "is", "the", "address", "of", "an", "int64", "variable", "that", "stores", "the", "value", "of", "t...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L66-L70
152,959
jwaldrip/odin
cli/flag_definitions.go
DefineInt64FlagVar
func (cmd *CLI) DefineInt64FlagVar(p *int64, name string, value int64, usage string) { cmd.DefineFlag(values.NewInt64(value, p), name, usage) }
go
func (cmd *CLI) DefineInt64FlagVar(p *int64, name string, value int64, usage string) { cmd.DefineFlag(values.NewInt64(value, p), name, usage) }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineInt64FlagVar", "(", "p", "*", "int64", ",", "name", "string", ",", "value", "int64", ",", "usage", "string", ")", "{", "cmd", ".", "DefineFlag", "(", "values", ".", "NewInt64", "(", "value", ",", "p", ")", ...
// DefineInt64FlagVar defines an int64 flag with specified name, default value, and usage string. // The argument p points to an int64 variable in which to store the value of the flag.
[ "DefineInt64FlagVar", "defines", "an", "int64", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "argument", "p", "points", "to", "an", "int64", "variable", "in", "which", "to", "store", "the", "value", "of", "th...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L74-L76
152,960
jwaldrip/odin
cli/flag_definitions.go
DefineIntFlag
func (cmd *CLI) DefineIntFlag(name string, value int, usage string) *int { p := new(int) cmd.DefineIntFlagVar(p, name, value, usage) return p }
go
func (cmd *CLI) DefineIntFlag(name string, value int, usage string) *int { p := new(int) cmd.DefineIntFlagVar(p, name, value, usage) return p }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineIntFlag", "(", "name", "string", ",", "value", "int", ",", "usage", "string", ")", "*", "int", "{", "p", ":=", "new", "(", "int", ")", "\n", "cmd", ".", "DefineIntFlagVar", "(", "p", ",", "name", ",", "...
// DefineIntFlag defines an int flag with specified name, default value, and usage string. // The return value is the address of an int variable that stores the value of the flag.
[ "DefineIntFlag", "defines", "an", "int", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "return", "value", "is", "the", "address", "of", "an", "int", "variable", "that", "stores", "the", "value", "of", "the", ...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L80-L84
152,961
jwaldrip/odin
cli/flag_definitions.go
DefineIntFlagVar
func (cmd *CLI) DefineIntFlagVar(p *int, name string, value int, usage string) { cmd.DefineFlag(values.NewInt(value, p), name, usage) }
go
func (cmd *CLI) DefineIntFlagVar(p *int, name string, value int, usage string) { cmd.DefineFlag(values.NewInt(value, p), name, usage) }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineIntFlagVar", "(", "p", "*", "int", ",", "name", "string", ",", "value", "int", ",", "usage", "string", ")", "{", "cmd", ".", "DefineFlag", "(", "values", ".", "NewInt", "(", "value", ",", "p", ")", ",", ...
// DefineIntFlagVar defines an int flag with specified name, default value, and usage string. // The argument p points to an int variable in which to store the value of the flag.
[ "DefineIntFlagVar", "defines", "an", "int", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "argument", "p", "points", "to", "an", "int", "variable", "in", "which", "to", "store", "the", "value", "of", "the", ...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L88-L90
152,962
jwaldrip/odin
cli/flag_definitions.go
DefineStringFlag
func (cmd *CLI) DefineStringFlag(name string, value string, usage string) *string { p := new(string) cmd.DefineStringFlagVar(p, name, value, usage) return p }
go
func (cmd *CLI) DefineStringFlag(name string, value string, usage string) *string { p := new(string) cmd.DefineStringFlagVar(p, name, value, usage) return p }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineStringFlag", "(", "name", "string", ",", "value", "string", ",", "usage", "string", ")", "*", "string", "{", "p", ":=", "new", "(", "string", ")", "\n", "cmd", ".", "DefineStringFlagVar", "(", "p", ",", "na...
// DefineStringFlag defines a string flag with specified name, default value, and usage string. // The return value is the address of a string variable that stores the value of the flag.
[ "DefineStringFlag", "defines", "a", "string", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "return", "value", "is", "the", "address", "of", "a", "string", "variable", "that", "stores", "the", "value", "of", "...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L94-L98
152,963
jwaldrip/odin
cli/flag_definitions.go
DefineStringFlagVar
func (cmd *CLI) DefineStringFlagVar(p *string, name string, value string, usage string) { cmd.DefineFlag(values.NewString(value, p), name, usage) }
go
func (cmd *CLI) DefineStringFlagVar(p *string, name string, value string, usage string) { cmd.DefineFlag(values.NewString(value, p), name, usage) }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineStringFlagVar", "(", "p", "*", "string", ",", "name", "string", ",", "value", "string", ",", "usage", "string", ")", "{", "cmd", ".", "DefineFlag", "(", "values", ".", "NewString", "(", "value", ",", "p", "...
// DefineStringFlagVar defines a string flag with specified name, default value, and usage string. // The argument p points to a string variable in which to store the value of the flag.
[ "DefineStringFlagVar", "defines", "a", "string", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "argument", "p", "points", "to", "a", "string", "variable", "in", "which", "to", "store", "the", "value", "of", "t...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L102-L104
152,964
jwaldrip/odin
cli/flag_definitions.go
DefineUint64Flag
func (cmd *CLI) DefineUint64Flag(name string, value uint64, usage string) *uint64 { p := new(uint64) cmd.DefineUint64FlagVar(p, name, value, usage) return p }
go
func (cmd *CLI) DefineUint64Flag(name string, value uint64, usage string) *uint64 { p := new(uint64) cmd.DefineUint64FlagVar(p, name, value, usage) return p }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineUint64Flag", "(", "name", "string", ",", "value", "uint64", ",", "usage", "string", ")", "*", "uint64", "{", "p", ":=", "new", "(", "uint64", ")", "\n", "cmd", ".", "DefineUint64FlagVar", "(", "p", ",", "na...
// DefineUint64Flag defines a uint64 flag with specified name, default value, and usage string. // The return value is the address of a uint64 variable that stores the value of the flag.
[ "DefineUint64Flag", "defines", "a", "uint64", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "return", "value", "is", "the", "address", "of", "a", "uint64", "variable", "that", "stores", "the", "value", "of", "...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L108-L112
152,965
jwaldrip/odin
cli/flag_definitions.go
DefineUint64FlagVar
func (cmd *CLI) DefineUint64FlagVar(p *uint64, name string, value uint64, usage string) { cmd.DefineFlag(values.NewUint64(value, p), name, usage) }
go
func (cmd *CLI) DefineUint64FlagVar(p *uint64, name string, value uint64, usage string) { cmd.DefineFlag(values.NewUint64(value, p), name, usage) }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineUint64FlagVar", "(", "p", "*", "uint64", ",", "name", "string", ",", "value", "uint64", ",", "usage", "string", ")", "{", "cmd", ".", "DefineFlag", "(", "values", ".", "NewUint64", "(", "value", ",", "p", "...
// DefineUint64FlagVar defines a uint64 flag with specified name, default value, and usage string. // The argument p points to a uint64 variable in which to store the value of the flag.
[ "DefineUint64FlagVar", "defines", "a", "uint64", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "argument", "p", "points", "to", "a", "uint64", "variable", "in", "which", "to", "store", "the", "value", "of", "t...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L116-L118
152,966
jwaldrip/odin
cli/flag_definitions.go
DefineUintFlag
func (cmd *CLI) DefineUintFlag(name string, value uint, usage string) *uint { p := new(uint) cmd.DefineUintFlagVar(p, name, value, usage) return p }
go
func (cmd *CLI) DefineUintFlag(name string, value uint, usage string) *uint { p := new(uint) cmd.DefineUintFlagVar(p, name, value, usage) return p }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineUintFlag", "(", "name", "string", ",", "value", "uint", ",", "usage", "string", ")", "*", "uint", "{", "p", ":=", "new", "(", "uint", ")", "\n", "cmd", ".", "DefineUintFlagVar", "(", "p", ",", "name", ","...
// DefineUintFlag defines a uint flag with specified name, default value, and usage string. // The return value is the address of a uint variable that stores the value of the flag.
[ "DefineUintFlag", "defines", "a", "uint", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "return", "value", "is", "the", "address", "of", "a", "uint", "variable", "that", "stores", "the", "value", "of", "the", ...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L122-L126
152,967
jwaldrip/odin
cli/flag_definitions.go
DefineUintFlagVar
func (cmd *CLI) DefineUintFlagVar(p *uint, name string, value uint, usage string) { cmd.DefineFlag(values.NewUint(value, p), name, usage) }
go
func (cmd *CLI) DefineUintFlagVar(p *uint, name string, value uint, usage string) { cmd.DefineFlag(values.NewUint(value, p), name, usage) }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineUintFlagVar", "(", "p", "*", "uint", ",", "name", "string", ",", "value", "uint", ",", "usage", "string", ")", "{", "cmd", ".", "DefineFlag", "(", "values", ".", "NewUint", "(", "value", ",", "p", ")", ",...
// DefineUintFlagVar defines a uint flag with specified name, default value, and usage string. // The argument p points to a uint variable in which to store the value of the flag.
[ "DefineUintFlagVar", "defines", "a", "uint", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "argument", "p", "points", "to", "a", "uint", "variable", "in", "which", "to", "store", "the", "value", "of", "the", ...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L130-L132
152,968
jwaldrip/odin
cli/flag_definitions.go
DefineFlag
func (cmd *CLI) DefineFlag(value values.Value, name string, usage string) { // Remember the default value as a string; it won't change. flag := &Flag{ Name: name, Usage: usage, value: value, DefValue: value.String(), } _, alreadythere := cmd.flags[name] if alreadythere { cmd.panicf("flag redefined: %s", name) } if cmd.flags == nil { cmd.flags = make(flagMap) } cmd.flags[name] = flag }
go
func (cmd *CLI) DefineFlag(value values.Value, name string, usage string) { // Remember the default value as a string; it won't change. flag := &Flag{ Name: name, Usage: usage, value: value, DefValue: value.String(), } _, alreadythere := cmd.flags[name] if alreadythere { cmd.panicf("flag redefined: %s", name) } if cmd.flags == nil { cmd.flags = make(flagMap) } cmd.flags[name] = flag }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineFlag", "(", "value", "values", ".", "Value", ",", "name", "string", ",", "usage", "string", ")", "{", "// Remember the default value as a string; it won't change.", "flag", ":=", "&", "Flag", "{", "Name", ":", "name"...
// DefineFlag defines a flag with the specified name and usage string. The type and // value of the flag are represented by the first argument, of type Value, which // typically holds a user-defined implementation of Value. For instance, the // caller could create a flag that turns a comma-separated string into a slice // of strings by giving the slice the methods of Value; in particular, Set would // decompose the comma-separated string into the slice.
[ "DefineFlag", "defines", "a", "flag", "with", "the", "specified", "name", "and", "usage", "string", ".", "The", "type", "and", "value", "of", "the", "flag", "are", "represented", "by", "the", "first", "argument", "of", "type", "Value", "which", "typically", ...
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_definitions.go#L140-L156
152,969
Scalingo/go-etcd-lock
lock/lockmock/gomock_locker.go
NewMockLocker
func NewMockLocker(ctrl *gomock.Controller) *MockLocker { mock := &MockLocker{ctrl: ctrl} mock.recorder = &MockLockerMockRecorder{mock} return mock }
go
func NewMockLocker(ctrl *gomock.Controller) *MockLocker { mock := &MockLocker{ctrl: ctrl} mock.recorder = &MockLockerMockRecorder{mock} return mock }
[ "func", "NewMockLocker", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockLocker", "{", "mock", ":=", "&", "MockLocker", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockLockerMockRecorder", "{", "mock", "}", "\n"...
// NewMockLocker creates a new mock instance
[ "NewMockLocker", "creates", "a", "new", "mock", "instance" ]
fecab5a750cc9a7c7665e5f83943b4d40ae227c5
https://github.com/Scalingo/go-etcd-lock/blob/fecab5a750cc9a7c7665e5f83943b4d40ae227c5/lock/lockmock/gomock_locker.go#L25-L29
152,970
jwaldrip/odin
cli/subCommand_definitions.go
DefineSubCommand
func (cmd *CLI) DefineSubCommand(name string, desc string, fn func(Command), paramNames ...string) *SubCommand { return cmd.AddSubCommand( NewSubCommand(name, desc, fn, paramNames...), ) }
go
func (cmd *CLI) DefineSubCommand(name string, desc string, fn func(Command), paramNames ...string) *SubCommand { return cmd.AddSubCommand( NewSubCommand(name, desc, fn, paramNames...), ) }
[ "func", "(", "cmd", "*", "CLI", ")", "DefineSubCommand", "(", "name", "string", ",", "desc", "string", ",", "fn", "func", "(", "Command", ")", ",", "paramNames", "...", "string", ")", "*", "SubCommand", "{", "return", "cmd", ".", "AddSubCommand", "(", ...
// DefineSubCommand defines and adds a SubCommand on the current command
[ "DefineSubCommand", "defines", "and", "adds", "a", "SubCommand", "on", "the", "current", "command" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/subCommand_definitions.go#L4-L8
152,971
jwaldrip/odin
cli/subCommand_definitions.go
AddSubCommands
func (cmd *CLI) AddSubCommands(subcmds ...*SubCommand) { for _, subcmd := range subcmds { cmd.AddSubCommand(subcmd) } }
go
func (cmd *CLI) AddSubCommands(subcmds ...*SubCommand) { for _, subcmd := range subcmds { cmd.AddSubCommand(subcmd) } }
[ "func", "(", "cmd", "*", "CLI", ")", "AddSubCommands", "(", "subcmds", "...", "*", "SubCommand", ")", "{", "for", "_", ",", "subcmd", ":=", "range", "subcmds", "{", "cmd", ".", "AddSubCommand", "(", "subcmd", ")", "\n", "}", "\n", "}" ]
// AddSubCommands adds subcommands to a command
[ "AddSubCommands", "adds", "subcommands", "to", "a", "command" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/subCommand_definitions.go#L11-L15
152,972
jwaldrip/odin
cli/subCommand_definitions.go
AddSubCommand
func (cmd *CLI) AddSubCommand(subcmd *SubCommand) *SubCommand { subcmd.ErrorHandling = cmd.ErrorHandling cmd.subCommands.Add(subcmd.name, subcmd) if subcmd.parent != nil { panic("command already assigned") } if &subcmd.CLI == cmd { panic("cannot assign subcmd to itself as a subcmd") } subcmd.parent = cmd return subcmd }
go
func (cmd *CLI) AddSubCommand(subcmd *SubCommand) *SubCommand { subcmd.ErrorHandling = cmd.ErrorHandling cmd.subCommands.Add(subcmd.name, subcmd) if subcmd.parent != nil { panic("command already assigned") } if &subcmd.CLI == cmd { panic("cannot assign subcmd to itself as a subcmd") } subcmd.parent = cmd return subcmd }
[ "func", "(", "cmd", "*", "CLI", ")", "AddSubCommand", "(", "subcmd", "*", "SubCommand", ")", "*", "SubCommand", "{", "subcmd", ".", "ErrorHandling", "=", "cmd", ".", "ErrorHandling", "\n", "cmd", ".", "subCommands", ".", "Add", "(", "subcmd", ".", "name"...
// AddSubCommand adds a subcommand to a command
[ "AddSubCommand", "adds", "a", "subcommand", "to", "a", "command" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/subCommand_definitions.go#L18-L29
152,973
jwaldrip/odin
cli/values/UintValue.go
NewUint
func NewUint(val uint, p *uint) *Uint { *p = val return (*Uint)(p) }
go
func NewUint(val uint, p *uint) *Uint { *p = val return (*Uint)(p) }
[ "func", "NewUint", "(", "val", "uint", ",", "p", "*", "uint", ")", "*", "Uint", "{", "*", "p", "=", "val", "\n", "return", "(", "*", "Uint", ")", "(", "p", ")", "\n", "}" ]
// NewUint returns a new uint value
[ "NewUint", "returns", "a", "new", "uint", "value" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/values/UintValue.go#L10-L13
152,974
jwaldrip/odin
cli/values/Bool.go
NewBool
func NewBool(val bool, p *bool) *Bool { *p = val return (*Bool)(p) }
go
func NewBool(val bool, p *bool) *Bool { *p = val return (*Bool)(p) }
[ "func", "NewBool", "(", "val", "bool", ",", "p", "*", "bool", ")", "*", "Bool", "{", "*", "p", "=", "val", "\n", "return", "(", "*", "Bool", ")", "(", "p", ")", "\n", "}" ]
// NewBool returns a new bool value
[ "NewBool", "returns", "a", "new", "bool", "value" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/values/Bool.go#L10-L13
152,975
jwaldrip/odin
cli/ParamsList.go
Compare
func (l paramsList) Compare(Y paramsList) paramsList { m := make(map[*Param]int) for _, y := range Y { m[y]++ } var ret paramsList for _, x := range l { if m[x] > 0 { m[x]-- continue } ret = append(ret, x) } return ret }
go
func (l paramsList) Compare(Y paramsList) paramsList { m := make(map[*Param]int) for _, y := range Y { m[y]++ } var ret paramsList for _, x := range l { if m[x] > 0 { m[x]-- continue } ret = append(ret, x) } return ret }
[ "func", "(", "l", "paramsList", ")", "Compare", "(", "Y", "paramsList", ")", "paramsList", "{", "m", ":=", "make", "(", "map", "[", "*", "Param", "]", "int", ")", "\n\n", "for", "_", ",", "y", ":=", "range", "Y", "{", "m", "[", "y", "]", "++", ...
// Compare compares two lists and returns the difference
[ "Compare", "compares", "two", "lists", "and", "returns", "the", "difference" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/ParamsList.go#L7-L24
152,976
jwaldrip/odin
cli/ParamsList.go
Names
func (l paramsList) Names() []string { var names []string for _, item := range l { names = append(names, item.Name) } return names }
go
func (l paramsList) Names() []string { var names []string for _, item := range l { names = append(names, item.Name) } return names }
[ "func", "(", "l", "paramsList", ")", "Names", "(", ")", "[", "]", "string", "{", "var", "names", "[", "]", "string", "\n", "for", "_", ",", "item", ":=", "range", "l", "{", "names", "=", "append", "(", "names", ",", "item", ".", "Name", ")", "\...
// Names returns the list of parameters names as a slice of strings
[ "Names", "returns", "the", "list", "of", "parameters", "names", "as", "a", "slice", "of", "strings" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/ParamsList.go#L27-L33
152,977
jwaldrip/odin
examples/greet-with/main.go
greet
func greet(c cli.Command) { greeting := c.Param("greeting") str := fmt.Sprintf("%s", greeting) str = styleByFlags(str, c) c.Println(str) }
go
func greet(c cli.Command) { greeting := c.Param("greeting") str := fmt.Sprintf("%s", greeting) str = styleByFlags(str, c) c.Println(str) }
[ "func", "greet", "(", "c", "cli", ".", "Command", ")", "{", "greeting", ":=", "c", ".", "Param", "(", "\"", "\"", ")", "\n", "str", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "greeting", ")", "\n", "str", "=", "styleByFlags", "(", "str", ...
// the greet command run by the root command
[ "the", "greet", "command", "run", "by", "the", "root", "command" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/examples/greet-with/main.go#L44-L49
152,978
jwaldrip/odin
cli/flag_inheritance.go
InheritFlags
func (cmd *CLI) InheritFlags(names ...string) { for _, name := range names { cmd.InheritFlag(name) } }
go
func (cmd *CLI) InheritFlags(names ...string) { for _, name := range names { cmd.InheritFlag(name) } }
[ "func", "(", "cmd", "*", "CLI", ")", "InheritFlags", "(", "names", "...", "string", ")", "{", "for", "_", ",", "name", ":=", "range", "names", "{", "cmd", ".", "InheritFlag", "(", "name", ")", "\n", "}", "\n", "}" ]
// InheritFlags allow flag values inherit from the commands parent
[ "InheritFlags", "allow", "flag", "values", "inherit", "from", "the", "commands", "parent" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_inheritance.go#L4-L8
152,979
jwaldrip/odin
cli/flag_inheritance.go
InheritFlag
func (cmd *CLI) InheritFlag(name string) { if cmd.parent == nil { panic("command does not have a parent") } flag := cmd.parent.(*CLI).getFlag(name) if cmd.inheritedFlags == nil { cmd.inheritedFlags = make(flagMap) } cmd.inheritedFlags[name] = flag }
go
func (cmd *CLI) InheritFlag(name string) { if cmd.parent == nil { panic("command does not have a parent") } flag := cmd.parent.(*CLI).getFlag(name) if cmd.inheritedFlags == nil { cmd.inheritedFlags = make(flagMap) } cmd.inheritedFlags[name] = flag }
[ "func", "(", "cmd", "*", "CLI", ")", "InheritFlag", "(", "name", "string", ")", "{", "if", "cmd", ".", "parent", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "flag", ":=", "cmd", ".", "parent", ".", "(", "*", "CLI", ")", ...
// InheritFlag allows a flags value to inherit from the commands parent
[ "InheritFlag", "allows", "a", "flags", "value", "to", "inherit", "from", "the", "commands", "parent" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_inheritance.go#L11-L20
152,980
jwaldrip/odin
cli/flag_inheritance.go
SubCommandsInheritFlags
func (cmd *CLI) SubCommandsInheritFlags(names ...string) { for _, name := range names { cmd.SubCommandsInheritFlag(name) } }
go
func (cmd *CLI) SubCommandsInheritFlags(names ...string) { for _, name := range names { cmd.SubCommandsInheritFlag(name) } }
[ "func", "(", "cmd", "*", "CLI", ")", "SubCommandsInheritFlags", "(", "names", "...", "string", ")", "{", "for", "_", ",", "name", ":=", "range", "names", "{", "cmd", ".", "SubCommandsInheritFlag", "(", "name", ")", "\n", "}", "\n", "}" ]
// SubCommandsInheritFlags tells all subcommands to inherit flags
[ "SubCommandsInheritFlags", "tells", "all", "subcommands", "to", "inherit", "flags" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_inheritance.go#L31-L35
152,981
jwaldrip/odin
cli/flag_inheritance.go
SubCommandsInheritFlag
func (cmd *CLI) SubCommandsInheritFlag(name string) { flag := cmd.getFlag(name) if cmd.propogatingFlags == nil { cmd.propogatingFlags = make(flagMap) } cmd.propogatingFlags[name] = flag }
go
func (cmd *CLI) SubCommandsInheritFlag(name string) { flag := cmd.getFlag(name) if cmd.propogatingFlags == nil { cmd.propogatingFlags = make(flagMap) } cmd.propogatingFlags[name] = flag }
[ "func", "(", "cmd", "*", "CLI", ")", "SubCommandsInheritFlag", "(", "name", "string", ")", "{", "flag", ":=", "cmd", ".", "getFlag", "(", "name", ")", "\n", "if", "cmd", ".", "propogatingFlags", "==", "nil", "{", "cmd", ".", "propogatingFlags", "=", "m...
// SubCommandsInheritFlag tells all subcommands to inherit a flag
[ "SubCommandsInheritFlag", "tells", "all", "subcommands", "to", "inherit", "a", "flag" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/flag_inheritance.go#L38-L44
152,982
jwaldrip/odin
cli/shellTable.go
NewSharedShellTable
func NewSharedShellTable(sep *string, widPtr *[]int) *ShellTable { return &ShellTable{separator: sep, maxColumnWidths: widPtr} }
go
func NewSharedShellTable(sep *string, widPtr *[]int) *ShellTable { return &ShellTable{separator: sep, maxColumnWidths: widPtr} }
[ "func", "NewSharedShellTable", "(", "sep", "*", "string", ",", "widPtr", "*", "[", "]", "int", ")", "*", "ShellTable", "{", "return", "&", "ShellTable", "{", "separator", ":", "sep", ",", "maxColumnWidths", ":", "widPtr", "}", "\n", "}" ]
// NewSharedShellTable initialized and returns a new ShellTable with shared ptrs
[ "NewSharedShellTable", "initialized", "and", "returns", "a", "new", "ShellTable", "with", "shared", "ptrs" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/shellTable.go#L29-L31
152,983
jwaldrip/odin
cli/shellTable.go
Row
func (t *ShellTable) Row() *ShellTableRow { newRow := &ShellTableRow{} t.rows = append(t.rows, newRow) return newRow }
go
func (t *ShellTable) Row() *ShellTableRow { newRow := &ShellTableRow{} t.rows = append(t.rows, newRow) return newRow }
[ "func", "(", "t", "*", "ShellTable", ")", "Row", "(", ")", "*", "ShellTableRow", "{", "newRow", ":=", "&", "ShellTableRow", "{", "}", "\n", "t", ".", "rows", "=", "append", "(", "t", ".", "rows", ",", "newRow", ")", "\n", "return", "newRow", "\n", ...
// Row adds a new row to the shell table
[ "Row", "adds", "a", "new", "row", "to", "the", "shell", "table" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/shellTable.go#L34-L38
152,984
jwaldrip/odin
cli/shellTable.go
padded
func (t *ShellTable) padded() *ShellTable { maxColumnWidths := t.MaxColumnWidths() for _, r := range t.rows { for i, c := range r.columns { c.WriteString(padder(maxColumnWidths[i] - len(c.String()))) } } return t }
go
func (t *ShellTable) padded() *ShellTable { maxColumnWidths := t.MaxColumnWidths() for _, r := range t.rows { for i, c := range r.columns { c.WriteString(padder(maxColumnWidths[i] - len(c.String()))) } } return t }
[ "func", "(", "t", "*", "ShellTable", ")", "padded", "(", ")", "*", "ShellTable", "{", "maxColumnWidths", ":=", "t", ".", "MaxColumnWidths", "(", ")", "\n", "for", "_", ",", "r", ":=", "range", "t", ".", "rows", "{", "for", "i", ",", "c", ":=", "r...
// String returns the string table
[ "String", "returns", "the", "string", "table" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/shellTable.go#L41-L49
152,985
jwaldrip/odin
cli/shellTable.go
MaxColumnWidths
func (t *ShellTable) MaxColumnWidths() []int { if t.maxColumnWidths == nil { t.maxColumnWidths = &[]int{} } for _, r := range t.rows { for i, c := range r.columns { if len(*t.maxColumnWidths) == i { *t.maxColumnWidths = append(*t.maxColumnWidths, 0) } colWidth := len(c.String()) if colWidth > (*t.maxColumnWidths)[i] { (*t.maxColumnWidths)[i] = colWidth } } } return *t.maxColumnWidths }
go
func (t *ShellTable) MaxColumnWidths() []int { if t.maxColumnWidths == nil { t.maxColumnWidths = &[]int{} } for _, r := range t.rows { for i, c := range r.columns { if len(*t.maxColumnWidths) == i { *t.maxColumnWidths = append(*t.maxColumnWidths, 0) } colWidth := len(c.String()) if colWidth > (*t.maxColumnWidths)[i] { (*t.maxColumnWidths)[i] = colWidth } } } return *t.maxColumnWidths }
[ "func", "(", "t", "*", "ShellTable", ")", "MaxColumnWidths", "(", ")", "[", "]", "int", "{", "if", "t", ".", "maxColumnWidths", "==", "nil", "{", "t", ".", "maxColumnWidths", "=", "&", "[", "]", "int", "{", "}", "\n", "}", "\n", "for", "_", ",", ...
// MaxColumnWidths returns an array of max column widths for each column
[ "MaxColumnWidths", "returns", "an", "array", "of", "max", "column", "widths", "for", "each", "column" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/shellTable.go#L69-L85
152,986
jwaldrip/odin
cli/shellTable.go
Column
func (r *ShellTableRow) Column(strs ...string) *ShellTableColumn { newCol := &ShellTableColumn{new(bytes.Buffer)} r.columns = append(r.columns, newCol) newCol.WriteString(strings.Join(strs, " ")) return newCol }
go
func (r *ShellTableRow) Column(strs ...string) *ShellTableColumn { newCol := &ShellTableColumn{new(bytes.Buffer)} r.columns = append(r.columns, newCol) newCol.WriteString(strings.Join(strs, " ")) return newCol }
[ "func", "(", "r", "*", "ShellTableRow", ")", "Column", "(", "strs", "...", "string", ")", "*", "ShellTableColumn", "{", "newCol", ":=", "&", "ShellTableColumn", "{", "new", "(", "bytes", ".", "Buffer", ")", "}", "\n", "r", ".", "columns", "=", "append"...
// Column creates a new column
[ "Column", "creates", "a", "new", "column" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/shellTable.go#L88-L93
152,987
jwaldrip/odin
cli/freeform_args_access.go
Arg
func (cmd *CLI) Arg(index int) values.Value { return cmd.Args()[index] }
go
func (cmd *CLI) Arg(index int) values.Value { return cmd.Args()[index] }
[ "func", "(", "cmd", "*", "CLI", ")", "Arg", "(", "index", "int", ")", "values", ".", "Value", "{", "return", "cmd", ".", "Args", "(", ")", "[", "index", "]", "\n", "}" ]
// Arg takes a position of a remaining arg that was not parsed as a param
[ "Arg", "takes", "a", "position", "of", "a", "remaining", "arg", "that", "was", "not", "parsed", "as", "a", "param" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/freeform_args_access.go#L11-L13
152,988
k-sone/critbitgo
map.go
Keys
func (m *SortedMap) Keys() []string { keys := make([]string, 0, m.Size()) m.trie.Allprefixed([]byte{}, func(k []byte, v interface{}) bool { keys = append(keys, string(k)) return true }) return keys }
go
func (m *SortedMap) Keys() []string { keys := make([]string, 0, m.Size()) m.trie.Allprefixed([]byte{}, func(k []byte, v interface{}) bool { keys = append(keys, string(k)) return true }) return keys }
[ "func", "(", "m", "*", "SortedMap", ")", "Keys", "(", ")", "[", "]", "string", "{", "keys", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "m", ".", "Size", "(", ")", ")", "\n", "m", ".", "trie", ".", "Allprefixed", "(", "[", "]", "b...
// Returns a slice of sorted keys
[ "Returns", "a", "slice", "of", "sorted", "keys" ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/map.go#L37-L44
152,989
k-sone/critbitgo
map.go
Each
func (m *SortedMap) Each(prefix string, handle func(key string, value interface{}) bool) bool { return m.trie.Allprefixed([]byte(prefix), func(k []byte, v interface{}) bool { return handle(string(k), v) }) }
go
func (m *SortedMap) Each(prefix string, handle func(key string, value interface{}) bool) bool { return m.trie.Allprefixed([]byte(prefix), func(k []byte, v interface{}) bool { return handle(string(k), v) }) }
[ "func", "(", "m", "*", "SortedMap", ")", "Each", "(", "prefix", "string", ",", "handle", "func", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "bool", ")", "bool", "{", "return", "m", ".", "trie", ".", "Allprefixed", "(", "[", "]"...
// Executes a provided function for each element that has a given prefix. // if handle returns `false`, the iteration is aborted.
[ "Executes", "a", "provided", "function", "for", "each", "element", "that", "has", "a", "given", "prefix", ".", "if", "handle", "returns", "false", "the", "iteration", "is", "aborted", "." ]
658116ef1e826b72c603cfe2091b12503f9bca43
https://github.com/k-sone/critbitgo/blob/658116ef1e826b72c603cfe2091b12503f9bca43/map.go#L48-L52
152,990
jwaldrip/odin
cli/CLI.go
New
func New(version, desc string, fn func(Command), paramNames ...string) *CLI { nameParts := strings.Split(os.Args[0], "/") cli := new(CLI) cli.init(nameParts[len(nameParts)-1], desc, fn, paramNames...) cli.version = version cli.description = desc return cli }
go
func New(version, desc string, fn func(Command), paramNames ...string) *CLI { nameParts := strings.Split(os.Args[0], "/") cli := new(CLI) cli.init(nameParts[len(nameParts)-1], desc, fn, paramNames...) cli.version = version cli.description = desc return cli }
[ "func", "New", "(", "version", ",", "desc", "string", ",", "fn", "func", "(", "Command", ")", ",", "paramNames", "...", "string", ")", "*", "CLI", "{", "nameParts", ":=", "strings", ".", "Split", "(", "os", ".", "Args", "[", "0", "]", ",", "\"", ...
// New returns a new cli with the specified name and // error handling property.
[ "New", "returns", "a", "new", "cli", "with", "the", "specified", "name", "and", "error", "handling", "property", "." ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/CLI.go#L62-L69
152,991
jwaldrip/odin
cli/values/Map.go
Keys
func (v Map) Keys() []string { var keys []string for key := range v { keys = append(keys, key) } return keys }
go
func (v Map) Keys() []string { var keys []string for key := range v { keys = append(keys, key) } return keys }
[ "func", "(", "v", "Map", ")", "Keys", "(", ")", "[", "]", "string", "{", "var", "keys", "[", "]", "string", "\n", "for", "key", ":=", "range", "v", "{", "keys", "=", "append", "(", "keys", ",", "key", ")", "\n", "}", "\n", "return", "keys", "...
// Keys returns the keys of the value map
[ "Keys", "returns", "the", "keys", "of", "the", "value", "map" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/values/Map.go#L7-L13
152,992
jwaldrip/odin
cli/values/Map.go
Values
func (v Map) Values() List { var valueList List for _, value := range v { valueList = append(valueList, value) } return valueList }
go
func (v Map) Values() List { var valueList List for _, value := range v { valueList = append(valueList, value) } return valueList }
[ "func", "(", "v", "Map", ")", "Values", "(", ")", "List", "{", "var", "valueList", "List", "\n", "for", "_", ",", "value", ":=", "range", "v", "{", "valueList", "=", "append", "(", "valueList", ",", "value", ")", "\n", "}", "\n", "return", "valueLi...
// Values returns a ValueList of all the values in the map
[ "Values", "returns", "a", "ValueList", "of", "all", "the", "values", "in", "the", "map" ]
b2584086c5b5629ad26f4f82d704b08ff6fc2f4c
https://github.com/jwaldrip/odin/blob/b2584086c5b5629ad26f4f82d704b08ff6fc2f4c/cli/values/Map.go#L16-L22
152,993
schollz/org.eclipse.paho.mqtt.golang
client.go
SubscribeMultiple
func (c *Client) SubscribeMultiple(filters map[string]byte, callback MessageHandler) Token { var err error token := newToken(packets.Subscribe).(*SubscribeToken) DEBUG.Println(CLI, "enter SubscribeMultiple") if !c.IsConnected() { token.err = ErrNotConnected token.flowComplete() return token } sub := packets.NewControlPacket(packets.Subscribe).(*packets.SubscribePacket) if sub.Topics, sub.Qoss, err = validateSubscribeMap(filters); err != nil { token.err = err return token } if callback != nil { for topic := range filters { c.msgRouter.addRoute(topic, callback) } } token.subs = make([]string, len(sub.Topics)) copy(token.subs, sub.Topics) c.oboundP <- &PacketAndToken{p: sub, t: token} DEBUG.Println(CLI, "exit SubscribeMultiple") return token }
go
func (c *Client) SubscribeMultiple(filters map[string]byte, callback MessageHandler) Token { var err error token := newToken(packets.Subscribe).(*SubscribeToken) DEBUG.Println(CLI, "enter SubscribeMultiple") if !c.IsConnected() { token.err = ErrNotConnected token.flowComplete() return token } sub := packets.NewControlPacket(packets.Subscribe).(*packets.SubscribePacket) if sub.Topics, sub.Qoss, err = validateSubscribeMap(filters); err != nil { token.err = err return token } if callback != nil { for topic := range filters { c.msgRouter.addRoute(topic, callback) } } token.subs = make([]string, len(sub.Topics)) copy(token.subs, sub.Topics) c.oboundP <- &PacketAndToken{p: sub, t: token} DEBUG.Println(CLI, "exit SubscribeMultiple") return token }
[ "func", "(", "c", "*", "Client", ")", "SubscribeMultiple", "(", "filters", "map", "[", "string", "]", "byte", ",", "callback", "MessageHandler", ")", "Token", "{", "var", "err", "error", "\n", "token", ":=", "newToken", "(", "packets", ".", "Subscribe", ...
// SubscribeMultiple starts a new subscription for multiple topics. Provide a MessageHandler to // be executed when a message is published on one of the topics provided.
[ "SubscribeMultiple", "starts", "a", "new", "subscription", "for", "multiple", "topics", ".", "Provide", "a", "MessageHandler", "to", "be", "executed", "when", "a", "message", "is", "published", "on", "one", "of", "the", "topics", "provided", "." ]
6d626954dc988ae6c25b0fdaabdb64f144c438b0
https://github.com/schollz/org.eclipse.paho.mqtt.golang/blob/6d626954dc988ae6c25b0fdaabdb64f144c438b0/client.go#L499-L524
152,994
schollz/org.eclipse.paho.mqtt.golang
client.go
Unsubscribe
func (c *Client) Unsubscribe(topics ...string) Token { token := newToken(packets.Unsubscribe).(*UnsubscribeToken) DEBUG.Println(CLI, "enter Unsubscribe") if !c.IsConnected() { token.err = ErrNotConnected token.flowComplete() return token } unsub := packets.NewControlPacket(packets.Unsubscribe).(*packets.UnsubscribePacket) unsub.Topics = make([]string, len(topics)) copy(unsub.Topics, topics) c.oboundP <- &PacketAndToken{p: unsub, t: token} for _, topic := range topics { c.msgRouter.deleteRoute(topic) } DEBUG.Println(CLI, "exit Unsubscribe") return token }
go
func (c *Client) Unsubscribe(topics ...string) Token { token := newToken(packets.Unsubscribe).(*UnsubscribeToken) DEBUG.Println(CLI, "enter Unsubscribe") if !c.IsConnected() { token.err = ErrNotConnected token.flowComplete() return token } unsub := packets.NewControlPacket(packets.Unsubscribe).(*packets.UnsubscribePacket) unsub.Topics = make([]string, len(topics)) copy(unsub.Topics, topics) c.oboundP <- &PacketAndToken{p: unsub, t: token} for _, topic := range topics { c.msgRouter.deleteRoute(topic) } DEBUG.Println(CLI, "exit Unsubscribe") return token }
[ "func", "(", "c", "*", "Client", ")", "Unsubscribe", "(", "topics", "...", "string", ")", "Token", "{", "token", ":=", "newToken", "(", "packets", ".", "Unsubscribe", ")", ".", "(", "*", "UnsubscribeToken", ")", "\n", "DEBUG", ".", "Println", "(", "CLI...
// Unsubscribe will end the subscription from each of the topics provided. // Messages published to those topics from other clients will no longer be // received.
[ "Unsubscribe", "will", "end", "the", "subscription", "from", "each", "of", "the", "topics", "provided", ".", "Messages", "published", "to", "those", "topics", "from", "other", "clients", "will", "no", "longer", "be", "received", "." ]
6d626954dc988ae6c25b0fdaabdb64f144c438b0
https://github.com/schollz/org.eclipse.paho.mqtt.golang/blob/6d626954dc988ae6c25b0fdaabdb64f144c438b0/client.go#L529-L548
152,995
sjmudd/stopwatch
stopwatch.go
Start
func Start(f func(time.Duration) string) *Stopwatch { s := New(f) s.Start() return s }
go
func Start(f func(time.Duration) string) *Stopwatch { s := New(f) s.Start() return s }
[ "func", "Start", "(", "f", "func", "(", "time", ".", "Duration", ")", "string", ")", "*", "Stopwatch", "{", "s", ":=", "New", "(", "f", ")", "\n", "s", ".", "Start", "(", ")", "\n\n", "return", "s", "\n", "}" ]
// Start returns a pointer to a new Stopwatch struct and indicates // that the stopwatch has started.
[ "Start", "returns", "a", "pointer", "to", "a", "new", "Stopwatch", "struct", "and", "indicates", "that", "the", "stopwatch", "has", "started", "." ]
f380bf8a9be1db68878b3ac5589c0a03d041f129
https://github.com/sjmudd/stopwatch/blob/f380bf8a9be1db68878b3ac5589c0a03d041f129/stopwatch.go#L54-L59
152,996
sjmudd/stopwatch
stopwatch.go
New
func New(f func(time.Duration) string) *Stopwatch { s := new(Stopwatch) s.format = f return s }
go
func New(f func(time.Duration) string) *Stopwatch { s := new(Stopwatch) s.format = f return s }
[ "func", "New", "(", "f", "func", "(", "time", ".", "Duration", ")", "string", ")", "*", "Stopwatch", "{", "s", ":=", "new", "(", "Stopwatch", ")", "\n", "s", ".", "format", "=", "f", "\n\n", "return", "s", "\n", "}" ]
// New returns a pointer to a new Stopwatch struct.
[ "New", "returns", "a", "pointer", "to", "a", "new", "Stopwatch", "struct", "." ]
f380bf8a9be1db68878b3ac5589c0a03d041f129
https://github.com/sjmudd/stopwatch/blob/f380bf8a9be1db68878b3ac5589c0a03d041f129/stopwatch.go#L62-L67
152,997
sjmudd/stopwatch
stopwatch.go
Start
func (s *Stopwatch) Start() { s.Lock() defer s.Unlock() if !s.isRunning() { s.refTime = time.Now() } }
go
func (s *Stopwatch) Start() { s.Lock() defer s.Unlock() if !s.isRunning() { s.refTime = time.Now() } }
[ "func", "(", "s", "*", "Stopwatch", ")", "Start", "(", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n\n", "if", "!", "s", ".", "isRunning", "(", ")", "{", "s", ".", "refTime", "=", "time", ".", "Now", ...
// Start records that we are now running. // If called previously this is a no-op and the existing refTime // is not touched.
[ "Start", "records", "that", "we", "are", "now", "running", ".", "If", "called", "previously", "this", "is", "a", "no", "-", "op", "and", "the", "existing", "refTime", "is", "not", "touched", "." ]
f380bf8a9be1db68878b3ac5589c0a03d041f129
https://github.com/sjmudd/stopwatch/blob/f380bf8a9be1db68878b3ac5589c0a03d041f129/stopwatch.go#L72-L79
152,998
sjmudd/stopwatch
stopwatch.go
Stop
func (s *Stopwatch) Stop() { s.Lock() defer s.Unlock() if s.isRunning() { s.elapsedTime += time.Since(s.refTime) s.refTime = time.Time{} } else { fmt.Printf("WARNING: Stopwatch.Stop() isRunning is false\n") } }
go
func (s *Stopwatch) Stop() { s.Lock() defer s.Unlock() if s.isRunning() { s.elapsedTime += time.Since(s.refTime) s.refTime = time.Time{} } else { fmt.Printf("WARNING: Stopwatch.Stop() isRunning is false\n") } }
[ "func", "(", "s", "*", "Stopwatch", ")", "Stop", "(", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n\n", "if", "s", ".", "isRunning", "(", ")", "{", "s", ".", "elapsedTime", "+=", "time", ".", "Since", ...
// Stop collects the elapsed time if running and remembers we are // not running.
[ "Stop", "collects", "the", "elapsed", "time", "if", "running", "and", "remembers", "we", "are", "not", "running", "." ]
f380bf8a9be1db68878b3ac5589c0a03d041f129
https://github.com/sjmudd/stopwatch/blob/f380bf8a9be1db68878b3ac5589c0a03d041f129/stopwatch.go#L83-L93
152,999
sjmudd/stopwatch
stopwatch.go
Reset
func (s *Stopwatch) Reset() { s.Lock() defer s.Unlock() if s.isRunning() { fmt.Printf("WARNING: Stopwatch.Reset() isRunning is true\n") } s.refTime = time.Time{} s.elapsedTime = 0 }
go
func (s *Stopwatch) Reset() { s.Lock() defer s.Unlock() if s.isRunning() { fmt.Printf("WARNING: Stopwatch.Reset() isRunning is true\n") } s.refTime = time.Time{} s.elapsedTime = 0 }
[ "func", "(", "s", "*", "Stopwatch", ")", "Reset", "(", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n\n", "if", "s", ".", "isRunning", "(", ")", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ")", ...
// Reset resets the counters.
[ "Reset", "resets", "the", "counters", "." ]
f380bf8a9be1db68878b3ac5589c0a03d041f129
https://github.com/sjmudd/stopwatch/blob/f380bf8a9be1db68878b3ac5589c0a03d041f129/stopwatch.go#L96-L105