package main import ( "errors" "fmt" "os" "os/exec" "git.theodohertyfamily.com/tools/wg-wrap/internal/cli" ) func main() { app := cli.NewApp(os.Args) // 1. Routing Phase: Handle diagnostic and management commands first. // These should run in the current namespace/context. if err := app.Route(); err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) // Propagate the exact exit code if the wrapped command failed with a non-zero exit status. var exitErr *exec.ExitError if errors.As(err, &exitErr) { os.Exit(exitErr.ExitCode()) } os.Exit(1) } }