added ls-icons command

This commit is contained in:
yusing
2024-10-04 10:04:18 +08:00
parent 9c3edff92b
commit fab39a461f
4 changed files with 119 additions and 6 deletions

View File

@@ -57,7 +57,7 @@ func main() {
}
if args.Command == common.CommandReload {
if err := query.ReloadServer(); err.HasError() {
if err := query.ReloadServer(); err != nil {
log.Fatal(err)
}
log.Print("ok")
@@ -94,7 +94,7 @@ func main() {
return
case common.CommandListRoutes:
routes, err := query.ListRoutes()
if err.HasError() {
if err != nil {
log.Printf("failed to connect to api server: %s", err)
log.Printf("falling back to config file")
printJSON(cfg.RoutesByAlias())
@@ -102,6 +102,13 @@ func main() {
printJSON(routes)
}
return
case common.CommandListIcons:
icons, err := internal.ListAvailableIcons()
if err != nil {
log.Fatal(err)
}
printJSON(icons)
return
case common.CommandDebugListEntries:
printJSON(cfg.DumpEntries())
return
@@ -110,7 +117,7 @@ func main() {
return
case common.CommandDebugListMTrace:
trace, err := query.ListMiddlewareTraces()
if err.HasError() {
if err != nil {
log.Fatal(err)
}
printJSON(trace)
@@ -213,7 +220,7 @@ func funcName(f func()) string {
func printJSON(obj any) {
j, err := E.Check(json.MarshalIndent(obj, "", " "))
if err.HasError() {
if err != nil {
logrus.Fatal(err)
}
rawLogger := log.New(os.Stdout, "", 0)