Commit c3d5f9fd authored by Kegan's avatar Kegan
Browse files

initial commit

parent a05af3b5
package argparse
import (
"os"
"strings"
)
var arguments map[string]string
var initialized bool
func InitArgs() {
initialized = true
arguments = make(map[string]string)
for _, arg := range os.Args {
parts := strings.Split(arg, "=")
if len(parts) > 1 {
if strings.Index(parts[0], "-") == 0 {
value := strings.Join(parts[1:], "=")
key := strings.ToLower(parts[0][1:])
arguments[key] = value
}
}
}
}
func GetArg(key string, defaultval string) string {
if !initialized {
InitArgs()
}
value := arguments[strings.ToLower(key)]
if value == "" {
return defaultval
}
return value
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment