From 10dab5a5c94ac49d6e0ef984911744d370d07e38 Mon Sep 17 00:00:00 2001 From: finn Date: Tue, 25 Oct 2022 16:17:44 -0700 Subject: [PATCH] allow updating more of the profile --- .../cmd/account/setprofile/set-profile.go | 26 +++++++++++++------ cmd/signaldctl/cmd/session/root.go | 1 - signald/signald.go | 1 - 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cmd/signaldctl/cmd/account/setprofile/set-profile.go b/cmd/signaldctl/cmd/account/setprofile/set-profile.go index a1c646a..1d99673 100644 --- a/cmd/signaldctl/cmd/account/setprofile/set-profile.go +++ b/cmd/signaldctl/cmd/account/setprofile/set-profile.go @@ -27,10 +27,14 @@ import ( var ( account string + name string + avatar string + emoji string + about string SetProfileCmd = &cobra.Command{ - Use: "set-profile name", - Short: "updates the profile data with a new name", + Use: "set-profile [name]", + Short: "update an account's profile data", PreRun: func(cmd *cobra.Command, args []string) { if account == "" { account = config.Config.DefaultAccount @@ -39,16 +43,19 @@ var ( common.Must(cmd.Help()) log.Fatal("No account specified. Please specify with --account or set a default") } - if len(args) != 1 { - common.Must(cmd.Help()) - log.Fatal("must specify a name") + + if len(args) > 0 { + name = args[0] } }, - Run: func(_ *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { go common.Signald.Listen(nil) req := v1.SetProfile{ - Account: account, - Name: args[0], + Account: account, + Name: name, + AvatarFile: avatar, + Emoji: emoji, + About: about, } err := req.Submit(common.Signald) if err != nil { @@ -61,4 +68,7 @@ var ( func init() { SetProfileCmd.Flags().StringVarP(&account, "account", "a", "", "the signald account to use") + SetProfileCmd.Flags().StringVarP(&avatar, "avatar", "A", "", "path to avatar file") + SetProfileCmd.Flags().StringVar(&emoji, "emoji", "", "an emoji to be shown next to the about section") + SetProfileCmd.Flags().StringVar(&about, "about", "", "profile about section") } diff --git a/cmd/signaldctl/cmd/session/root.go b/cmd/signaldctl/cmd/session/root.go index 29673b5..614b827 100644 --- a/cmd/signaldctl/cmd/session/root.go +++ b/cmd/signaldctl/cmd/session/root.go @@ -15,7 +15,6 @@ package session - import ( "github.com/spf13/cobra" ) diff --git a/signald/signald.go b/signald/signald.go index 202ec46..f790d0c 100644 --- a/signald/signald.go +++ b/signald/signald.go @@ -99,7 +99,6 @@ func (s *Signald) connect() error { return nil } - func (s *Signald) Close() error { return s.socket.Close() }