mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
For #28932 No functional changes. Left the parent directory (also named fleetctl) with the main package as is not to break/change any other flows. This PR is the first step before refactoring integration tests to speed up (parallelize) fleetctl tests.
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"io/fs"
|
|
"os"
|
|
"path"
|
|
"runtime"
|
|
|
|
"github.com/fleetdm/fleet/v4/cmd/fleetctl/fleetctl"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
func main() {
|
|
app := fleetctl.CreateApp(os.Stdin, os.Stdout, os.Stderr, exitErrHandler)
|
|
if err := app.Run(os.Args); err != nil {
|
|
fmt.Fprintf(os.Stdout, "Error: %+v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
// exitErrHandler implements cli.ExitErrHandlerFunc. If there is an error, prints it to stderr and exits with status 1.
|
|
func exitErrHandler(c *cli.Context, err error) {
|
|
if err == nil {
|
|
return
|
|
}
|
|
|
|
fmt.Fprintf(c.App.ErrWriter, "Error: %+v\n", err)
|
|
|
|
if errors.Is(err, fs.ErrPermission) {
|
|
switch runtime.GOOS {
|
|
case "darwin", "linux":
|
|
fmt.Fprintf(c.App.ErrWriter, "\nThis error can usually be resolved by fixing the permissions on the %s directory, or re-running this command with sudo.\n", path.Dir(c.String("config")))
|
|
case "windows":
|
|
fmt.Fprintf(c.App.ErrWriter, "\nThis error can usually be resolved by fixing the permissions on the %s directory, or re-running this command with 'Run as administrator'.\n", path.Dir(c.String("config")))
|
|
}
|
|
}
|
|
cli.OsExiter(1)
|
|
}
|