Add account delete to signaldctl
This commit is contained in:
parent
1eab1e7890
commit
3b5d9254f7
2 changed files with 55 additions and 0 deletions
53
cmd/signaldctl/cmd/account/delete/delete-account.go
Normal file
53
cmd/signaldctl/cmd/account/delete/delete-account.go
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
// Copyright © 2021 Finn Herzfeld <finn@janky.solutions>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package delete
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"gitlab.com/signald/signald-go/cmd/signaldctl/common"
|
||||||
|
"gitlab.com/signald/signald-go/signald/client-protocol/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
server bool
|
||||||
|
|
||||||
|
DeleteAccountCmd = &cobra.Command{
|
||||||
|
Use: "delete [phone number]",
|
||||||
|
Short: "delete an account from the local signald instance, and optionally from the server as well",
|
||||||
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
if len(args) != 1 {
|
||||||
|
common.Must(cmd.Help())
|
||||||
|
log.Fatal("must specify phone number")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Run: func(_ *cobra.Command, args []string) {
|
||||||
|
go common.Signald.Listen(nil)
|
||||||
|
req := v1.DeleteAccountRequest{Account: args[0]}
|
||||||
|
err := req.Submit(common.Signald)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("error from signald: ", err)
|
||||||
|
}
|
||||||
|
log.Println("account deleted")
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
DeleteAccountCmd.Flags().BoolVar(&server, "server", false, "delete the account from the server as well")
|
||||||
|
}
|
|
@ -18,6 +18,7 @@ package account
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/delete"
|
||||||
"gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/link"
|
"gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/link"
|
||||||
"gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/list"
|
"gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/list"
|
||||||
"gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/register"
|
"gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/register"
|
||||||
|
@ -30,6 +31,7 @@ var AccountCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
AccountCmd.AddCommand(delete.DeleteAccountCmd)
|
||||||
AccountCmd.AddCommand(link.LinkAccountCmd)
|
AccountCmd.AddCommand(link.LinkAccountCmd)
|
||||||
AccountCmd.AddCommand(list.ListAccountCmd)
|
AccountCmd.AddCommand(list.ListAccountCmd)
|
||||||
AccountCmd.AddCommand(register.RegisterAccountCmd)
|
AccountCmd.AddCommand(register.RegisterAccountCmd)
|
||||||
|
|
Loading…
Reference in a new issue