Fix when connect to socket happens

This commit is contained in:
Finn 2020-12-12 02:37:30 -08:00
parent e8e52b82a1
commit 5f435b488a

View file

@ -35,6 +35,13 @@ var RootCmd = &cobra.Command{
Use: "signald-cli",
Short: "Interact with a running siangld instance",
Long: `signald-cli is a command line tool to interact with signald.`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
s = &signald.Signald{SocketPath: socketPath}
err := s.Connect()
if err != nil {
log.Fatal(err)
}
},
}
// Execute adds all child commands to the root command sets flags appropriately.
@ -50,12 +57,6 @@ func init() {
cobra.OnInitialize(initConfig)
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.signald-cli.yaml)")
RootCmd.PersistentFlags().StringVarP(&socketPath, "socket", "s", "/var/run/signald/signald.sock", "the path to the signald socket file")
s = &signald.Signald{SocketPath: socketPath}
err := s.Connect()
if err != nil {
log.Fatal(err)
}
}
// initConfig reads in config file and ENV variables if set.