summaryrefslogtreecommitdiff
path: root/cmd/wg-wrap
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/wg-wrap')
-rw-r--r--cmd/wg-wrap/main.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/cmd/wg-wrap/main.go b/cmd/wg-wrap/main.go
new file mode 100644
index 0000000..7e2de9f
--- /dev/null
+++ b/cmd/wg-wrap/main.go
@@ -0,0 +1,27 @@
+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)
+ }
+}