refactor(commands): separate commands and its core into two folders (#32)
- I think it would be better if one for commands only, one for the spec handling core logic so people won't be confused by the core logic inside the commands folder (cleaner I guess) - Regen docs
This commit is contained in:
+9
-9
@@ -4,11 +4,11 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/versenilvis/iris/commands/core"
|
||||
"github.com/versenilvis/iris/spec"
|
||||
)
|
||||
|
||||
func envVarGenerator(tokens []string, _ string, _ string) []core.Suggestion {
|
||||
var results []core.Suggestion
|
||||
func envVarGenerator(tokens []string, _ string, _ string) []spec.Suggestion {
|
||||
var results []spec.Suggestion
|
||||
for _, env := range os.Environ() {
|
||||
parts := strings.SplitN(env, "=", 2)
|
||||
name := parts[0]
|
||||
@@ -20,36 +20,36 @@ func envVarGenerator(tokens []string, _ string, _ string) []core.Suggestion {
|
||||
val = val[:57] + "..."
|
||||
}
|
||||
}
|
||||
results = append(results, core.Suggestion{Cmd: name, Desc: val})
|
||||
results = append(results, spec.Suggestion{Cmd: name, Desc: val})
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
func init() {
|
||||
core.Register(&core.Spec{
|
||||
spec.Register(&spec.Spec{
|
||||
Name: "export",
|
||||
Description: "set environment variable",
|
||||
Generator: envVarGenerator,
|
||||
})
|
||||
|
||||
core.Register(&core.Spec{
|
||||
spec.Register(&spec.Spec{
|
||||
Name: "env",
|
||||
Description: "print environment",
|
||||
Generator: envVarGenerator,
|
||||
Options: []core.Option{
|
||||
Options: []spec.Option{
|
||||
{Name: "-i", Description: "start with empty env"},
|
||||
{Name: "-u", Description: "unset variable"},
|
||||
{Name: "-0", Description: "null delimited"},
|
||||
},
|
||||
})
|
||||
|
||||
core.Register(&core.Spec{
|
||||
spec.Register(&spec.Spec{
|
||||
Name: "printenv",
|
||||
Description: "print environment variables",
|
||||
Generator: envVarGenerator,
|
||||
})
|
||||
|
||||
core.Register(&core.Spec{
|
||||
spec.Register(&spec.Spec{
|
||||
Name: "unset",
|
||||
Description: "unset variable",
|
||||
Generator: envVarGenerator,
|
||||
|
||||
Reference in New Issue
Block a user