Every /api operation is registered with Huma behind one admin-token middleware, served at /api/openapi.json with a docs page at /api/docs, and committed as api/openapi.yaml, which task check keeps current.
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
// Command archie is the single Archie binary. It parses flags and hands over to
|
|
// the composition root.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/samcharles93/archie-core/internal/app/archie"
|
|
"github.com/samcharles93/archie-core/internal/buildinfo"
|
|
)
|
|
|
|
func main() {
|
|
if err := run(); err != nil {
|
|
fmt.Fprintln(os.Stderr, "archie:", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func run() error {
|
|
configPath := flag.String("config", archie.DefaultConfigPath(), "path to the bootstrap config file")
|
|
newIdentity := flag.Bool("new-age-identity", false, "print a new age identity for age_identity and exit")
|
|
showVersion := buildinfo.RegisterVersionFlag("archie")
|
|
flag.Usage = func() {
|
|
_, _ = fmt.Fprintln(flag.CommandLine.Output(), "usage: archie [flags]\n archie openapi print the API's OpenAPI document")
|
|
flag.PrintDefaults()
|
|
}
|
|
flag.Parse()
|
|
showVersion()
|
|
if *newIdentity {
|
|
return archie.NewAgeIdentity(os.Stdout)
|
|
}
|
|
switch flag.Arg(0) {
|
|
case "":
|
|
case "openapi":
|
|
doc, err := archie.Document()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = os.Stdout.Write(doc)
|
|
return err
|
|
default:
|
|
return fmt.Errorf("unknown command %q", flag.Arg(0))
|
|
}
|
|
|
|
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
|
defer stop()
|
|
return archie.Run(ctx, *configPath)
|
|
}
|