You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
682 B
47 lines
682 B
2 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
"log"
|
||
|
"os"
|
||
|
|
||
|
"git.meatballhat.com/x/box-o-sand/argh"
|
||
2 years ago
|
"github.com/davecgh/go-spew/spew"
|
||
2 years ago
|
)
|
||
|
|
||
|
func main() {
|
||
2 years ago
|
asJSON := os.Getenv("ARGH_OUTPUT_JSON") == "enabled"
|
||
|
|
||
2 years ago
|
log.SetFlags(0)
|
||
|
|
||
2 years ago
|
pt, err := argh.ParseArgs(os.Args, argh.NewParserConfig(
|
||
|
&argh.CommandConfig{
|
||
|
NValue: argh.OneOrMoreValue,
|
||
|
ValueNames: []string{"topping"},
|
||
|
Flags: &argh.Flags{
|
||
|
Automatic: true,
|
||
|
},
|
||
|
},
|
||
|
nil,
|
||
|
))
|
||
2 years ago
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
2 years ago
|
ast := argh.NewQuerier(pt.Nodes).AST()
|
||
|
|
||
|
if asJSON {
|
||
|
b, err := json.MarshalIndent(ast, "", " ")
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
fmt.Println(string(b))
|
||
|
|
||
|
return
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
spew.Dump(ast)
|
||
2 years ago
|
}
|