allow updating more of the profile

This commit is contained in:
finn 2022-10-25 16:17:44 -07:00
parent 3e33f0a3f7
commit 10dab5a5c9
3 changed files with 18 additions and 10 deletions

View file

@ -27,10 +27,14 @@ import (
var ( var (
account string account string
name string
avatar string
emoji string
about string
SetProfileCmd = &cobra.Command{ SetProfileCmd = &cobra.Command{
Use: "set-profile name", Use: "set-profile [name]",
Short: "updates the profile data with a new name", Short: "update an account's profile data",
PreRun: func(cmd *cobra.Command, args []string) { PreRun: func(cmd *cobra.Command, args []string) {
if account == "" { if account == "" {
account = config.Config.DefaultAccount account = config.Config.DefaultAccount
@ -39,16 +43,19 @@ var (
common.Must(cmd.Help()) common.Must(cmd.Help())
log.Fatal("No account specified. Please specify with --account or set a default") log.Fatal("No account specified. Please specify with --account or set a default")
} }
if len(args) != 1 {
common.Must(cmd.Help()) if len(args) > 0 {
log.Fatal("must specify a name") name = args[0]
} }
}, },
Run: func(_ *cobra.Command, args []string) { Run: func(_ *cobra.Command, _ []string) {
go common.Signald.Listen(nil) go common.Signald.Listen(nil)
req := v1.SetProfile{ req := v1.SetProfile{
Account: account, Account: account,
Name: args[0], Name: name,
AvatarFile: avatar,
Emoji: emoji,
About: about,
} }
err := req.Submit(common.Signald) err := req.Submit(common.Signald)
if err != nil { if err != nil {
@ -61,4 +68,7 @@ var (
func init() { func init() {
SetProfileCmd.Flags().StringVarP(&account, "account", "a", "", "the signald account to use") 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")
} }

View file

@ -15,7 +15,6 @@
package session package session
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )

View file

@ -99,7 +99,6 @@ func (s *Signald) connect() error {
return nil return nil
} }
func (s *Signald) Close() error { func (s *Signald) Close() error {
return s.socket.Close() return s.socket.Close()
} }