fleet/cli/root.go

53 lines
1.3 KiB
Go
Raw Normal View History

2016-09-03 17:25:16 +00:00
package cli
import (
"fmt"
"os"
2016-09-26 18:48:55 +00:00
"github.com/kolide/kolide-ose/server/config"
2016-09-03 17:25:16 +00:00
"github.com/spf13/cobra"
)
// Launch is the entrypoint that sets up and runs the Kolide commands.
2016-09-03 17:25:16 +00:00
func Launch() {
rootCmd := createRootCmd()
configManager := config.NewManager(rootCmd)
rootCmd.AddCommand(createPrepareCmd(configManager))
rootCmd.AddCommand(createServeCmd(configManager))
rootCmd.AddCommand(createConfigDumpCmd(configManager))
rootCmd.AddCommand(createVersionCmd(configManager))
2016-09-03 17:25:16 +00:00
if err := rootCmd.Execute(); err != nil {
initFatal(err, "running root command")
2016-09-03 17:25:16 +00:00
}
}
// initFatal prints an error message and exits with a non-zero status.
func initFatal(err error, message string) {
fmt.Printf("Error %s: %v\n", message, err)
os.Exit(1)
}
func createRootCmd() *cobra.Command {
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "kolide",
Short: "osquery management and orchestration",
Long: `
2016-09-03 17:25:16 +00:00
osquery management and orchestration
Configurable Options:
Options may be supplied in a yaml configuration file or via environment
variables. You only need to define the configuration values for which you
wish to override the default value.
`,
}
2016-09-03 17:25:16 +00:00
rootCmd.PersistentFlags().StringP("config", "c", "", "Path to a configuration file")
2016-09-03 17:25:16 +00:00
return rootCmd
2016-09-03 17:25:16 +00:00
}