diff --git a/cmd/server.go b/cmd/server.go index 918bf04..10b4bd1 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -31,6 +31,7 @@ func init() { rootCmd.AddCommand(serverCmd) serverCmd.PersistentFlags().StringP("port", "p", "1302", "port to use for listening") serverCmd.PersistentFlags().StringP("history", "r", "", "File to store and recover chat history from") + serverCmd.PersistentFlags().String("password", "", "Password for accessing the chat server") } func setServerParameters(cmd *cobra.Command) error { @@ -49,5 +50,12 @@ func setServerParameters(cmd *cobra.Command) error { logLocation = parameterHistory isLogging = true } + parPassword, err := cmd.Flags().GetString("password") + if err != nil { + return err + } + if parPassword != "" { + password = parPassword + } return nil }