From b112886093100dffb8325a8d3b70598943e29d9a Mon Sep 17 00:00:00 2001 From: Finn Date: Sat, 12 Dec 2020 16:33:29 -0800 Subject: [PATCH] Rename command line tool to signaldctl --- .gitignore | 2 +- .gitlab-ci.yml | 4 ++-- Makefile | 4 ++-- cmd/{signald-cli => signaldctl}/cmd/link.go | 2 +- cmd/{signald-cli => signaldctl}/cmd/listAccounts.go | 2 +- cmd/{signald-cli => signaldctl}/cmd/listGroups.go | 2 +- cmd/{signald-cli => signaldctl}/cmd/register.go | 4 ++-- cmd/{signald-cli => signaldctl}/cmd/root.go | 12 ++++++------ cmd/{signald-cli => signaldctl}/cmd/send.go | 0 cmd/{signald-cli => signaldctl}/cmd/verify.go | 2 +- cmd/{signald-cli => signaldctl}/cmd/version.go | 0 cmd/{signald-cli => signaldctl}/main.go | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) rename cmd/{signald-cli => signaldctl}/cmd/link.go (97%) rename cmd/{signald-cli => signaldctl}/cmd/listAccounts.go (96%) rename cmd/{signald-cli => signaldctl}/cmd/listGroups.go (96%) rename cmd/{signald-cli => signaldctl}/cmd/register.go (94%) rename cmd/{signald-cli => signaldctl}/cmd/root.go (84%) rename cmd/{signald-cli => signaldctl}/cmd/send.go (100%) rename cmd/{signald-cli => signaldctl}/cmd/verify.go (97%) rename cmd/{signald-cli => signaldctl}/cmd/version.go (100%) rename cmd/{signald-cli => signaldctl}/main.go (92%) diff --git a/.gitignore b/.gitignore index 35ec54d..10f4b32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/signald-cli +/signaldctl # Binaries for programs and plugins *.exe diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a8b6c29..5cc0503 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,8 +23,8 @@ build: - cp -r * /go/src/gitlab.com/signald/signald-go - cd /go/src/gitlab.com/signald/signald-go script: - - go build -o "${CI_PROJECT_DIR}/signald-cli" ./cmd/signald-cli + - go build -o "${CI_PROJECT_DIR}/signaldctl" ./cmd/signaldctl artifacts: paths: - - signald-cli + - signaldctl expire_in: 1 month diff --git a/Makefile b/Makefile index f95d203..1333aeb 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -signald-cli: signald/client-protocol - go build -o signald-cli ./cmd/signald-cli +signaldctl: signald/client-protocol + go build -o signaldctl ./cmd/signaldctl protocol.json: echo '{"type": "protocol", "version": "v1alpha1"}' | nc -q0 -U /var/run/signald/signald.sock | jq 'select(.type == "protocol").data' > protocol.json diff --git a/cmd/signald-cli/cmd/link.go b/cmd/signaldctl/cmd/link.go similarity index 97% rename from cmd/signald-cli/cmd/link.go rename to cmd/signaldctl/cmd/link.go index 2f6c3bd..9d0038a 100644 --- a/cmd/signald-cli/cmd/link.go +++ b/cmd/signaldctl/cmd/link.go @@ -35,7 +35,7 @@ var linkCmd = &cobra.Command{ Short: "Link to an existing Signal account", Long: `Get a URI or QR code to link to an existing Signal account`, Run: func(cmd *cobra.Command, args []string) { - requestID := fmt.Sprint("signald-cli-", rand.Intn(1000)) + requestID := fmt.Sprint("signaldctl-", rand.Intn(1000)) err := s.RawRequest(v0.LegacyRequest{ Type: "link", ID: requestID, diff --git a/cmd/signald-cli/cmd/listAccounts.go b/cmd/signaldctl/cmd/listAccounts.go similarity index 96% rename from cmd/signald-cli/cmd/listAccounts.go rename to cmd/signaldctl/cmd/listAccounts.go index 265cf06..b65c582 100644 --- a/cmd/signald-cli/cmd/listAccounts.go +++ b/cmd/signaldctl/cmd/listAccounts.go @@ -31,7 +31,7 @@ var listAccountsCmd = &cobra.Command{ Short: "list of all the accounts registered to this signald instance.", Long: `Prints a list of all users to stdout.`, Run: func(cmd *cobra.Command, args []string) { - requestID := fmt.Sprint("signald-cli-", rand.Intn(1000)) + requestID := fmt.Sprint("signaldctl-", rand.Intn(1000)) err := s.RawRequest(v0.LegacyRequest{ Type: "list_accounts", ID: requestID, diff --git a/cmd/signald-cli/cmd/listGroups.go b/cmd/signaldctl/cmd/listGroups.go similarity index 96% rename from cmd/signald-cli/cmd/listGroups.go rename to cmd/signaldctl/cmd/listGroups.go index c40bf49..b12a141 100644 --- a/cmd/signald-cli/cmd/listGroups.go +++ b/cmd/signaldctl/cmd/listGroups.go @@ -31,7 +31,7 @@ var listGroupsCmd = &cobra.Command{ Short: "list of all the groups that the user is in.", Long: `Prints a list of all groups the user is in to stdout.`, Run: func(cmd *cobra.Command, args []string) { - requestID := fmt.Sprint("signald-cli-", rand.Intn(1000)) + requestID := fmt.Sprint("signaldctl-", rand.Intn(1000)) err := s.RawRequest(v0.LegacyRequest{ Type: "list_groups", Username: username, diff --git a/cmd/signald-cli/cmd/register.go b/cmd/signaldctl/cmd/register.go similarity index 94% rename from cmd/signald-cli/cmd/register.go rename to cmd/signaldctl/cmd/register.go index 7868a8c..77a5b67 100644 --- a/cmd/signald-cli/cmd/register.go +++ b/cmd/signaldctl/cmd/register.go @@ -31,7 +31,7 @@ var registerCmd = &cobra.Command{ Short: "Register a new account.", Long: `Register a new signal account, generating new keys if the number was previously registered.`, Run: func(cmd *cobra.Command, args []string) { - requestID := fmt.Sprint("signald-cli-", rand.Intn(1000)) + requestID := fmt.Sprint("signaldctl-", rand.Intn(1000)) err := s.RawRequest(v0.LegacyRequest{ Type: "register", Username: username, @@ -48,7 +48,7 @@ var registerCmd = &cobra.Command{ if err != nil { log.Fatal("error rendering response:", err) } - fmt.Println("validation code requested. submit the code using signald-cli verify", string(account)) + fmt.Println("validation code requested. submit the code using signaldctl verify", string(account)) }, } diff --git a/cmd/signald-cli/cmd/root.go b/cmd/signaldctl/cmd/root.go similarity index 84% rename from cmd/signald-cli/cmd/root.go rename to cmd/signaldctl/cmd/root.go index 9a96616..11fe156 100644 --- a/cmd/signald-cli/cmd/root.go +++ b/cmd/signaldctl/cmd/root.go @@ -32,9 +32,9 @@ var s *signald.Signald // RootCmd represents the base command when called without any subcommands var RootCmd = &cobra.Command{ - Use: "signald-cli", + Use: "signaldctl", Short: "Interact with a running siangld instance", - Long: `signald-cli is a command line tool to interact with signald.`, + Long: `signaldctl is a command line tool to interact with signald.`, PersistentPreRun: func(cmd *cobra.Command, args []string) { s = &signald.Signald{SocketPath: socketPath} err := s.Connect() @@ -55,7 +55,7 @@ func Execute() { func init() { cobra.OnInitialize(initConfig) - RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.signald-cli.yaml)") + RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.signaldctl.yaml)") RootCmd.PersistentFlags().StringVarP(&socketPath, "socket", "s", "/var/run/signald/signald.sock", "the path to the signald socket file") } @@ -65,9 +65,9 @@ func initConfig() { viper.SetConfigFile(cfgFile) } - viper.SetConfigName(".signald-cli") // name of config file (without extension) - viper.AddConfigPath("$HOME") // adding home directory as first search path - viper.AutomaticEnv() // read in environment variables that match + viper.SetConfigName(".signaldctl") // name of config file (without extension) + viper.AddConfigPath("$HOME") // adding home directory as first search path + viper.AutomaticEnv() // read in environment variables that match // If a config file is found, read it in. if err := viper.ReadInConfig(); err == nil { diff --git a/cmd/signald-cli/cmd/send.go b/cmd/signaldctl/cmd/send.go similarity index 100% rename from cmd/signald-cli/cmd/send.go rename to cmd/signaldctl/cmd/send.go diff --git a/cmd/signald-cli/cmd/verify.go b/cmd/signaldctl/cmd/verify.go similarity index 97% rename from cmd/signald-cli/cmd/verify.go rename to cmd/signaldctl/cmd/verify.go index 3dea1d3..5bd5d3a 100644 --- a/cmd/signald-cli/cmd/verify.go +++ b/cmd/signaldctl/cmd/verify.go @@ -35,7 +35,7 @@ var verify = &cobra.Command{ Short: "Verify an account confirmation code and complete account setup", Long: `Verify the phone number on a new account by submitting a verification code, completing the account registration process.`, Run: func(cmd *cobra.Command, args []string) { - requestID := fmt.Sprint("signald-cli-", rand.Intn(1000)) + requestID := fmt.Sprint("signaldctl-", rand.Intn(1000)) err := s.RawRequest(v0.LegacyRequest{ Type: "verify", Username: username, diff --git a/cmd/signald-cli/cmd/version.go b/cmd/signaldctl/cmd/version.go similarity index 100% rename from cmd/signald-cli/cmd/version.go rename to cmd/signaldctl/cmd/version.go diff --git a/cmd/signald-cli/main.go b/cmd/signaldctl/main.go similarity index 92% rename from cmd/signald-cli/main.go rename to cmd/signaldctl/main.go index c3d5ba1..d86fdff 100644 --- a/cmd/signald-cli/main.go +++ b/cmd/signaldctl/main.go @@ -15,7 +15,7 @@ package main -import "gitlab.com/signald/signald-go/cmd/signald-cli/cmd" +import "gitlab.com/signald/signald-go/cmd/signaldctl/cmd" func main() { cmd.Execute()