2022-05-12 02:11:05 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"git.meatballhat.com/x/box-o-sand/argh"
|
2022-05-29 23:16:13 +00:00
|
|
|
"github.com/davecgh/go-spew/spew"
|
2022-05-12 02:11:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2022-05-29 23:16:13 +00:00
|
|
|
asJSON := os.Getenv("ARGH_OUTPUT_JSON") == "enabled"
|
|
|
|
|
2022-05-14 00:58:55 +00:00
|
|
|
log.SetFlags(0)
|
|
|
|
|
2022-06-04 21:38:24 +00:00
|
|
|
pt, err := argh.ParseArgs(os.Args, argh.NewParserConfig(
|
|
|
|
&argh.CommandConfig{
|
|
|
|
NValue: argh.OneOrMoreValue,
|
|
|
|
ValueNames: []string{"topping"},
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Automatic: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
nil,
|
|
|
|
))
|
2022-05-12 02:11:05 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-05-29 23:16:13 +00:00
|
|
|
ast := argh.NewQuerier(pt.Nodes).AST()
|
|
|
|
|
|
|
|
if asJSON {
|
|
|
|
b, err := json.MarshalIndent(ast, "", " ")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(string(b))
|
|
|
|
|
|
|
|
return
|
2022-05-12 02:11:05 +00:00
|
|
|
}
|
|
|
|
|
2022-05-29 23:16:13 +00:00
|
|
|
spew.Dump(ast)
|
2022-05-12 02:11:05 +00:00
|
|
|
}
|