blob: 7e2de9f635569534ec18b8a7a8a93311dbc4093a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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)
}
}
|