From be6e342d4b474421c3a38a51cf760bc1ec649fa0 Mon Sep 17 00:00:00 2001 From: Micah Yeager <42281448+micah-yeager@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:49:19 -0400 Subject: [PATCH] feat: emit explicit errors for the `service` command on unsupported OSes --- cmd/cloudflared/generic_service.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cmd/cloudflared/generic_service.go b/cmd/cloudflared/generic_service.go index 7fc8c5e6..764d362f 100644 --- a/cmd/cloudflared/generic_service.go +++ b/cmd/cloudflared/generic_service.go @@ -3,11 +3,36 @@ package main import ( + "fmt" "os" cli "github.com/urfave/cli/v2" ) func runApp(app *cli.App, graceShutdownC chan struct{}) { + app.Commands = append(app.Commands, &cli.Command{ + Name: "service", + Usage: "Manages the cloudflared system service (not supported on this operating system)", + Subcommands: []*cli.Command{ + { + Name: "install", + Usage: "Install cloudflared as a system service (not supported on this operating system)", + Action: cliutil.ConfiguredAction(installGenericService), + }, + { + Name: "uninstall", + Usage: "Uninstall the cloudflared service (not supported on this operating system)", + Action: cliutil.ConfiguredAction(uninstallGenericService), + }, + }, + }) app.Run(os.Args) } + +func installGenericService(c *cli.Context) error { + return fmt.Errorf("service installation is not supported on this operating system") +} + +func uninstallGenericService(c *cli.Context) error { + return fmt.Errorf("service uninstallation is not supported on this operating system") +}