From e27f1aed3497b89d1750bbc1456828abf9c13487 Mon Sep 17 00:00:00 2001 From: bright-poku Date: Fri, 19 Feb 2021 13:14:59 -0500 Subject: [PATCH 1/5] rename clients to apps --- .idea/.gitignore | 8 ++++++++ .idea/auth0-cli.iml | 9 +++++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ internal/cli/clients.go | 14 +++++++------- 5 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/auth0-cli.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 000000000..73f69e095 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/auth0-cli.iml b/.idea/auth0-cli.iml new file mode 100644 index 000000000..5e764c4f0 --- /dev/null +++ b/.idea/auth0-cli.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..c6c7795b7 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..94a25f7f4 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/internal/cli/clients.go b/internal/cli/clients.go index ebeb33227..7a09bb377 100644 --- a/internal/cli/clients.go +++ b/internal/cli/clients.go @@ -13,8 +13,8 @@ import ( func clientsCmd(cli *cli) *cobra.Command { cmd := &cobra.Command{ - Use: "clients", - Short: "Manage resources for clients", + Use: "apps", + Short: "Manage resources for apps", } cmd.SetUsageTemplate(resourceUsageTemplate()) @@ -27,15 +27,15 @@ func clientsCmd(cli *cli) *cobra.Command { func clientsListCmd(cli *cli) *cobra.Command { cmd := &cobra.Command{ Use: "list", - Short: "List your existing clients", + Short: "List your existing apps", Long: `auth0 client list -Lists your existing clients. To create one try: +Lists your existing apps. To create one try: - auth0 clients create + auth0 apps create `, RunE: func(cmd *cobra.Command, args []string) error { var list *management.ClientList - err := ansi.Spinner("Loading clients", func() error { + err := ansi.Spinner("Loading apps", func() error { var err error list, err = cli.api.Client.List() return err @@ -66,7 +66,7 @@ func clientsCreateCmd(cli *cli) *cobra.Command { Short: "Create a new client (also know as application)", Long: `Create a new client (or application): -auth0 clients create --name myapp --type [native|spa|regular|m2m] +auth0 apps create --name myapp --type [native|spa|regular|m2m] - supported application type: `, From eb6ccacec64bb4087305527dc1085ad0c4758600 Mon Sep 17 00:00:00 2001 From: bright-poku Date: Fri, 19 Feb 2021 18:04:48 -0500 Subject: [PATCH 2/5] rename clients to app and added delete command --- internal/cli/clients.go | 65 +++++++++++++++++++++++++++++++++++------ internal/cli/root.go | 2 +- 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/internal/cli/clients.go b/internal/cli/clients.go index 7a09bb377..4bab8342b 100644 --- a/internal/cli/clients.go +++ b/internal/cli/clients.go @@ -11,24 +11,25 @@ import ( "gopkg.in/auth0.v5/management" ) -func clientsCmd(cli *cli) *cobra.Command { +func appsCmd(cli *cli) *cobra.Command { cmd := &cobra.Command{ Use: "apps", Short: "Manage resources for apps", } cmd.SetUsageTemplate(resourceUsageTemplate()) - cmd.AddCommand(clientsListCmd(cli)) - cmd.AddCommand(clientsCreateCmd(cli)) + cmd.AddCommand(appsListCmd(cli)) + cmd.AddCommand(appsCreateCmd(cli)) + cmd.AddCommand(appsDeleteCmd(cli)) return cmd } -func clientsListCmd(cli *cli) *cobra.Command { +func appsListCmd(cli *cli) *cobra.Command { cmd := &cobra.Command{ Use: "list", Short: "List your existing apps", - Long: `auth0 client list + Long: `auth0 app list Lists your existing apps. To create one try: auth0 apps create @@ -53,7 +54,53 @@ Lists your existing apps. To create one try: return cmd } -func clientsCreateCmd(cli *cli) *cobra.Command { +func appsDeleteCmd(cli *cli) *cobra.Command { + var flags struct { + AppID string + } + cmd := &cobra.Command{ + Use: "delete", + Short: "Delete an existing app", + Long: `auth0 apps delete --name appName + +auth0 apps delete --app-id myapp + +`, + RunE: func(cmd *cobra.Command, args []string) error { + + if !cmd.Flags().Changed("app-id") { + qs := []*survey.Question{ + { + Name: "AppID", + Prompt: &survey.Input{ + Message: "AppID:", + Default: "My App", + Help: "ID of the application to delete.", + }, + }, + } + + err := survey.Ask(qs, &flags) + if err != nil { + return err + } + } + c := &management.Client{ + ClientID: &flags.AppID, + } + + return ansi.Spinner("Deleting application", func() error { + return cli.api.Client.Delete(*c.ClientID) + }) + }, + } + + cmd.Flags().StringVarP(&flags.AppID, "app-id", "i", "", "app-id of the app.") + + return cmd +} + +func appsCreateCmd(cli *cli) *cobra.Command { var flags struct { Name string AppType string @@ -63,8 +110,8 @@ func clientsCreateCmd(cli *cli) *cobra.Command { } cmd := &cobra.Command{ Use: "create", - Short: "Create a new client (also know as application)", - Long: `Create a new client (or application): + Short: "Create a new application", + Long: `Create a new application: auth0 apps create --name myapp --type [native|spa|regular|m2m] @@ -155,7 +202,7 @@ auth0 apps create --name myapp --type [native|spa|regular|m2m] "- regular: Traditional web app using redirects.\n"+ "- m2m (machine to machine): CLIs, daemons or services running on your backend.") cmd.Flags().StringVarP(&flags.Description, "description", "d", "", "A free text description of the application. Max character count is 140.") - cmd.Flags().StringSliceVarP(&flags.Callbacks, "callbacks", "c", nil, "After the user authenticates we will only call back to any of these URLs. You can specify multiple valid URLs by comma-separating them (typically to handle different environments like QA or testing). Make sure to specify the protocol (https://) otherwise the callback may fail in some cases. With the exception of custom URI schemes for native clients, all callbacks should use protocol https://.") + cmd.Flags().StringSliceVarP(&flags.Callbacks, "callbacks", "c", nil, "After the user authenticates we will only call back to any of these URLs. You can specify multiple valid URLs by comma-separating them (typically to handle different environments like QA or testing). Make sure to specify the protocol (https://) otherwise the callback may fail in some cases. With the exception of custom URI schemes for native apps, all callbacks should use protocol https://.") cmd.Flags().StringVar(&flags.TokenEndpointAuthMethod, "auth-method", "", "Defines the requested authentication method for the token endpoint. Possible values are 'None' (public application without a client secret), 'Post' (application uses HTTP POST parameters) or 'Basic' (application uses HTTP Basic).") diff --git a/internal/cli/root.go b/internal/cli/root.go index 6772d7d47..8892ee257 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -60,7 +60,7 @@ func Execute() { // so add new commands in a place that reflect its relevance or relation with other commands: rootCmd.AddCommand(loginCmd(cli)) rootCmd.AddCommand(quickstartCmd(cli)) - rootCmd.AddCommand(clientsCmd(cli)) + rootCmd.AddCommand(appsCmd(cli)) rootCmd.AddCommand(apisCmd(cli)) rootCmd.AddCommand(tryLoginCmd(cli)) rootCmd.AddCommand(logsCmd(cli)) From 4ed4a05320067383829d4d83ab4466fd331f3bad Mon Sep 17 00:00:00 2001 From: bright-poku <75628344+bright-poku@users.noreply.github.com> Date: Fri, 19 Feb 2021 18:17:01 -0500 Subject: [PATCH 3/5] Delete .idea directory --- .idea/.gitignore | 8 -------- .idea/auth0-cli.iml | 9 --------- .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ 4 files changed, 31 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/auth0-cli.iml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 73f69e095..000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/auth0-cli.iml b/.idea/auth0-cli.iml deleted file mode 100644 index 5e764c4f0..000000000 --- a/.idea/auth0-cli.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index c6c7795b7..000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7f4..000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 3a3b01f5c1a98ed47e978aad69404f367277b694 Mon Sep 17 00:00:00 2001 From: bright-poku Date: Fri, 19 Feb 2021 18:39:58 -0500 Subject: [PATCH 4/5] renamed clientsListCmd to appsListCmd --- internal/cli/clients_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cli/clients_test.go b/internal/cli/clients_test.go index 90d483cd7..9157c12f6 100644 --- a/internal/cli/clients_test.go +++ b/internal/cli/clients_test.go @@ -42,7 +42,7 @@ func TestClientsListCmd(t *testing.T) { api: &auth0.API{Client: clientAPI}, } - cmd := clientsListCmd(cli) + cmd := appsListCmd(cli) if err := cmd.Execute(); err != nil { t.Fatal(err) From bb865e6e5233f9086e5fd8c2f8e1542fe951cd87 Mon Sep 17 00:00:00 2001 From: bright-poku <75628344+bright-poku@users.noreply.github.com> Date: Fri, 19 Feb 2021 19:14:36 -0500 Subject: [PATCH 5/5] Update internal/cli/clients.go Co-authored-by: Cyril David --- internal/cli/clients.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cli/clients.go b/internal/cli/clients.go index 4bab8342b..237e15c97 100644 --- a/internal/cli/clients.go +++ b/internal/cli/clients.go @@ -29,7 +29,7 @@ func appsListCmd(cli *cli) *cobra.Command { cmd := &cobra.Command{ Use: "list", Short: "List your existing apps", - Long: `auth0 app list + Long: `auth0 apps list Lists your existing apps. To create one try: auth0 apps create