Skip to content

Commit

Permalink
Add csv format to table views (#955)
Browse files Browse the repository at this point in the history
* Add csv format to table views

Adds csv as a general format cli wide for all table viewable commands
  • Loading branch information
Michael Christenson II authored Jan 4, 2024
1 parent 12ca7e5 commit 8ca147d
Show file tree
Hide file tree
Showing 39 changed files with 204 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ tags
.DS_Store
.idea
.env
.envrc

# Vendor
vendor
Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_actions_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ auth0 actions list [flags]
auth0 actions list
auth0 actions ls
auth0 actions ls --json
auth0 actions ls --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
```

Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_apis_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ auth0 apis list [flags]
auth0 apis ls
auth0 apis ls --number 100
auth0 apis ls -n 100 --json
auth0 apis ls --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
-n, --number int Number of APIs to retrieve. Minimum 1, maximum 1000. (default 100)
```
Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_apis_scopes_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ auth0 apis scopes list [flags]
auth0 apis scopes list
auth0 apis scopes ls <api-id|api-audience>
auth0 apis scopes ls <api-id|api-audience> --json
auth0 apis scopes ls <api-id|api-audience> --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
```

Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_apps_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ auth0 apps list [flags]
auth0 apps list --reveal-secrets
auth0 apps list --reveal-secrets --number 100
auth0 apps ls -r -n 100 --json
auth0 apps ls --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
-n, --number int Number of apps to retrieve. Minimum 1, maximum 1000. (default 100)
-r, --reveal-secrets Display the application secrets ('signing_keys', 'client_secret') as part of the command output.
Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_domains_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ auth0 domains list [flags]
auth0 domains list
auth0 domains ls
auth0 domains ls --json
auth0 domains ls --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
```

Expand Down
3 changes: 3 additions & 0 deletions docs/auth0_logs_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ auth0 logs list [flags]
auth0 logs list --filter "ip:<ip>"
auth0 logs list --filter "type:f" # See the full list of type codes at https://auth0.com/docs/logs/log-event-type-codes
auth0 logs ls -n 250
auth0 logs ls --json
auth0 logs ls --csv
```


## Flags

```
--csv Output in csv format.
-f, --filter string Filter in Lucene query syntax. See https://auth0.com/docs/logs/log-search-query-syntax for more details.
--json Output in json format.
-n, --number int Number of log entries to show. Minimum 1, maximum 1000. (default 100)
Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_logs_streams_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ auth0 logs streams list [flags]
auth0 logs streams list
auth0 logs streams ls
auth0 logs streams ls --json
auth0 logs streams ls --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
```

Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_orgs_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ auth0 orgs list [flags]
auth0 orgs list
auth0 orgs ls
auth0 orgs ls --json
auth0 orgs ls --csv
auth0 orgs ls -n 100
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
-n, --number int Number of organizations to retrieve. Minimum 1, maximum 1000. (default 100)
```
Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_orgs_members_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ auth0 orgs members list [flags]
auth0 orgs members ls <org-id>
auth0 orgs members list <org-id> --number 100
auth0 orgs members ls <org-id> -n 100 --json
auth0 orgs members ls <org-id> --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
-n, --number int Number of organization members to retrieve. Minimum 1, maximum 1000. (default 100)
```
Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_orgs_roles_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ auth0 orgs roles list [flags]
auth0 orgs roles ls <org-id>
auth0 orgs roles list <org-id> --number 100
auth0 orgs roles ls <org-id> -n 100 --json
auth0 orgs roles ls <org-id> --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
-n, --number int Number of organization roles to retrieve. Minimum 1, maximum 1000. (default 100)
```
Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_orgs_roles_members_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ auth0 orgs roles members list [flags]
auth0 orgs roles members list <org-id> --role-id role --number 100
auth0 orgs roles members ls <org-id> -r role -n 100
auth0 orgs roles members ls <org-id> -r role -n 100 --json
auth0 orgs roles members ls <org-id> --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
-n, --number int Number of members to retrieve. Minimum 1, maximum 1000. (default 100)
-r, --role-id string Role Identifier.
Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_quickstarts_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ auth0 quickstarts list [flags]
auth0 qs list
auth0 qs ls
auth0 qs ls --json
auth0 qs ls --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
```

Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_roles_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ auth0 roles list [flags]
auth0 roles ls
auth0 roles ls --number 100
auth0 roles ls -n 100 --json
auth0 roles ls --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
-n, --number int Number of roles to retrieve. Minimum 1, maximum 1000. (default 100)
```
Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_roles_permissions_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ auth0 roles permissions list [flags]
auth0 roles permissions ls <role-id>
auth0 roles permissions ls <role-id> --number 100
auth0 roles permissions ls <role-id> -n 100 --json
auth0 roles permissions ls <role-id> --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
-n, --number int Number of permissions to retrieve. Minimum 1, maximum 1000. (default 100)
```
Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_rules_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ auth0 rules list [flags]
auth0 rules list
auth0 rules ls
auth0 rules ls --json
auth0 rules ls --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
```

Expand Down
8 changes: 8 additions & 0 deletions docs/auth0_tenants_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ auth0 tenants list [flags]
```
auth0 tenants list
auth0 tenants ls
auth0 tenants ls --json
auth0 tenants ls --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
```


## Inherited Flags
Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_users_blocks_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ auth0 users blocks list [flags]
auth0 users blocks list <user-id|username|email|phone-number> --json
auth0 users blocks list "auth0|61b5b6e90783fa19f7c57dad"
auth0 users blocks list "[email protected]"
auth0 users blocks list <user-id|username|email|phone-number> --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
```

Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_users_roles_show.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ auth0 users roles show [flags]
auth0 users roles show <user-id>
auth0 users roles show <user-id> --number 100
auth0 users roles show <user-id> -n 100 --json
auth0 users roles show <user-id> --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
-n, --number int Number of user roles to retrieve. Minimum 1, maximum 1000. (default 100)
```
Expand Down
2 changes: 2 additions & 0 deletions docs/auth0_users_search.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ auth0 users search [flags]
auth0 users search --query name:"Bob" --sort "name:1"
auth0 users search -q name:"Bob" -s "name:1" --number 200
auth0 users search -q name:"Bob" -s "name:1" -n 200 --json
auth0 users search -q name:"Bob" -s "name:1" -n 200 --csv
```


## Flags

```
--csv Output in csv format.
--json Output in json format.
-n, --number int Number of users, that match the search criteria, to retrieve. Minimum 1, maximum 1000. If limit is hit, refine the search query. (default 100)
-q, --query email:"user123@*.com" OR (user_id:"user-id-123" AND name:"Bob") Search query in Lucene query syntax.
Expand Down
5 changes: 4 additions & 1 deletion internal/cli/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ func listActionsCmd(cli *cli) *cobra.Command {
Long: "List your existing actions. To create one, run: `auth0 actions create`.",
Example: ` auth0 actions list
auth0 actions ls
auth0 actions ls --json`,
auth0 actions ls --json
auth0 actions ls --csv`,
RunE: func(cmd *cobra.Command, args []string) error {
var list *management.ActionList

Expand All @@ -116,6 +117,8 @@ func listActionsCmd(cli *cli) *cobra.Command {
}

cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
cmd.Flags().BoolVar(&cli.csv, "csv", false, "Output in csv format.")
cmd.MarkFlagsMutuallyExclusive("json", "csv")

return cmd
}
Expand Down
11 changes: 9 additions & 2 deletions internal/cli/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ func listApisCmd(cli *cli) *cobra.Command {
Example: ` auth0 apis list
auth0 apis ls
auth0 apis ls --number 100
auth0 apis ls -n 100 --json`,
auth0 apis ls -n 100 --json
auth0 apis ls --csv`,
RunE: func(cmd *cobra.Command, args []string) error {
if inputs.Number < 1 || inputs.Number > 1000 {
return fmt.Errorf("number flag invalid, please pass a number between 1 and 1000")
Expand Down Expand Up @@ -156,6 +157,9 @@ func listApisCmd(cli *cli) *cobra.Command {
}

cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
cmd.Flags().BoolVar(&cli.csv, "csv", false, "Output in csv format.")
cmd.MarkFlagsMutuallyExclusive("json", "csv")

apiNumber.RegisterInt(cmd, &inputs.Number, defaultPageSize)

return cmd
Expand Down Expand Up @@ -528,7 +532,8 @@ func listScopesCmd(cli *cli) *cobra.Command {
Long: "List the scopes of an API. To update scopes, run: `auth0 apis update <id|audience> -s <scopes>`.",
Example: ` auth0 apis scopes list
auth0 apis scopes ls <api-id|api-audience>
auth0 apis scopes ls <api-id|api-audience> --json`,
auth0 apis scopes ls <api-id|api-audience> --json
auth0 apis scopes ls <api-id|api-audience> --csv`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
err := apiID.Pick(cmd, &inputs.ID, cli.apiPickerOptions)
Expand Down Expand Up @@ -556,6 +561,8 @@ func listScopesCmd(cli *cli) *cobra.Command {
}

cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
cmd.Flags().BoolVar(&cli.csv, "csv", false, "Output in csv format.")
cmd.MarkFlagsMutuallyExclusive("json", "csv")

return cmd
}
Expand Down
6 changes: 5 additions & 1 deletion internal/cli/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ func listAppsCmd(cli *cli) *cobra.Command {
auth0 apps ls
auth0 apps list --reveal-secrets
auth0 apps list --reveal-secrets --number 100
auth0 apps ls -r -n 100 --json`,
auth0 apps ls -r -n 100 --json
auth0 apps ls --csv`,
RunE: func(cmd *cobra.Command, args []string) error {
if inputs.Number < 1 || inputs.Number > 1000 {
return fmt.Errorf("number flag invalid, please pass a number between 1 and 1000")
Expand Down Expand Up @@ -258,6 +259,9 @@ func listAppsCmd(cli *cli) *cobra.Command {
}

cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
cmd.Flags().BoolVar(&cli.csv, "csv", false, "Output in csv format.")
cmd.MarkFlagsMutuallyExclusive("json", "csv")

revealSecrets.RegisterBool(cmd, &inputs.RevealSecrets, false)
appNumber.RegisterInt(cmd, &inputs.Number, defaultPageSize)

Expand Down
Loading

0 comments on commit 8ca147d

Please sign in to comment.