Merge branch 'fix_socket_path' into 'main'

issue #9: Fix SocketPath handling

See merge request signald/signald-go!3
This commit is contained in:
Finn 2021-04-05 22:24:13 +00:00
commit d44f76e716

View file

@ -69,11 +69,13 @@ func Execute() {
func init() {
cobra.OnInitialize(initConfig)
defaultConfigPath := fmt.Sprintf("%s/.config/signaldctl.yaml", os.Getenv("HOME"))
defaultSocketPath := ""
if os.Getenv("SIGNALDCTL_PUBLIC_DOC_MODE") == "on" {
defaultConfigPath = "~/.config/signaldctl.yaml"
defaultSocketPath = "/var/run/signald/signald.sock"
}
RootCmd.PersistentFlags().StringVar(&config.Path, "config", defaultConfigPath, "config file")
RootCmd.PersistentFlags().StringVar(&socketPath, "socket", "/var/run/signald/signald.sock", "the path to the signald socket file")
RootCmd.PersistentFlags().StringVar(&socketPath, "socket", defaultSocketPath, "the path to the signald socket file")
RootCmd.PersistentFlags().StringVarP(&common.OutputFormat, "output-format", "o", "default", "the output format. options are usually table, yaml and json, default is usually table. Some commands have other options.")
RootCmd.AddCommand(account.AccountCmd)
RootCmd.AddCommand(configcmd.ConfigCmd)