Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: improve long messages and render cli documentation
- Loading branch information
Showing
29 changed files
with
745 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/ory/kratos/cmd/remote" | ||
"github.com/spf13/cobra" | ||
"os" | ||
|
||
"github.com/ory/x/clidoc" | ||
|
||
"github.com/ory/kratos/cmd/identities" | ||
"github.com/ory/kratos/cmd/jsonnet" | ||
) | ||
|
||
func main() { | ||
rootCmd := &cobra.Command{ Use: "kratos" } | ||
identities.RegisterCommandRecursive(rootCmd) | ||
jsonnet.RegisterCommandRecursive(rootCmd) | ||
remote.RegisterCommandRecursive(rootCmd) | ||
|
||
if err := clidoc.Generate(rootCmd, os.Args[1:]); err != nil { | ||
_, _ = fmt.Fprintf(os.Stderr, "%+v", err) | ||
os.Exit(1) | ||
} | ||
fmt.Println("All files have been generated and updated.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,45 @@ | ||
package identities | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/ory/kratos/internal/clihelpers" | ||
"github.com/ory/kratos/internal/httpclient/models" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/ory/kratos/cmd/cliclient" | ||
"github.com/ory/kratos/internal/clihelpers" | ||
"github.com/ory/kratos/internal/httpclient/client/admin" | ||
"github.com/ory/x/cmdx" | ||
) | ||
|
||
var getCmd = &cobra.Command{ | ||
Use: "get <id>", | ||
Short: "Get an identity by ID", | ||
Args: cobra.ExactArgs(1), | ||
Use: "get <id-0 [id-1 ...]>", | ||
Short: "Get one or more identities by ID", | ||
Long: fmt.Sprintf(`This command gets all the details about an identity. To get an identity by some selector, e.g. the recovery email address, use the list command in combination with jq. | ||
Example: get the identities with the recovery email address at the domain "ory.sh": | ||
kratos identities get $(kratos identities list --format json | jq -r 'map(select(.recovery_addresses[].value | endswith("@ory.sh"))) | .[].id') | ||
%s | ||
`, clihelpers.WarningJQIsComplicated), | ||
Args: cobra.MinimumNArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
c := cliclient.NewClient(cmd) | ||
|
||
resp, err := c.Admin.GetIdentity(&admin.GetIdentityParams{ | ||
ID: args[0], | ||
Context: context.Background(), | ||
}) | ||
cmdx.Must(err, "Could not get identity \"%s\": %s", args[0], err) | ||
identities := make([]*models.Identity, 0, len(args)) | ||
for _, id := range args { | ||
resp, err := c.Admin.GetIdentity(admin.NewGetIdentityParamsWithTimeout(time.Second).WithID(id)) | ||
cmdx.Must(err, "Could not get identity \"%s\": %s", args[0], err) | ||
|
||
identities = append(identities, resp.Payload) | ||
} | ||
|
||
clihelpers.PrintRow(cmd, (*outputIdentity)(resp.Payload)) | ||
if len(identities) == 1 { | ||
clihelpers.PrintRow(cmd, (*outputIdentity)(identities[0])) | ||
return | ||
} | ||
clihelpers.PrintCollection(cmd, &outputIdentityCollection{identities}) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
id: kratos-identities-delete | ||
title: kratos identities delete | ||
description: kratos identities delete Delete identities by ID | ||
--- | ||
|
||
<!-- | ||
This file is auto-generated. | ||
To improve this file please make your change against the appropriate "./cmd/*.go" file. | ||
--> | ||
## kratos identities delete | ||
|
||
Delete identities by ID | ||
|
||
### Synopsis | ||
|
||
This command deletes one or more identities by ID. To delete an identity by some selector, e.g. the recovery email address, use the list command in combination with jq. | ||
Example: delete the identity with the recovery email address "foo@bar.com": | ||
|
||
kratos identities delete $(kratos identities list --format json | jq -r 'map(select(.recovery_addresses[].value == "foo@bar.com")) | .[].id') | ||
|
||
I have to admit, this is not easy if you don't speak jq fluently. What about opening an issue and telling us what predefined selectors you want to have? https://github.com/ory/kratos/issues/new/choose | ||
|
||
|
||
``` | ||
kratos identities delete <id-0 [id-1 ...]> [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for delete | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
-e, --endpoint string The upstream admin endpoint URL. Alternatively set using the KRATOS_ADMIN_ENDPOINT environmental variable. | ||
-f, --format string Set the output format. One of table, json, and json-pretty. | ||
-q, --quiet Prints only IDs, one per line. Takes precedence over --format. | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kratos identities](kratos-identities) - Tools to interact with remote identities | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
id: kratos-identities-get | ||
title: kratos identities get | ||
description: kratos identities get Get one or more identities by ID | ||
--- | ||
|
||
<!-- | ||
This file is auto-generated. | ||
To improve this file please make your change against the appropriate "./cmd/*.go" file. | ||
--> | ||
## kratos identities get | ||
|
||
Get one or more identities by ID | ||
|
||
### Synopsis | ||
|
||
This command gets all the details about an identity. To get an identity by some selector, e.g. the recovery email address, use the list command in combination with jq. | ||
Example: get the identities with the recovery email address at the domain "ory.sh": | ||
|
||
kratos identities get $(kratos identities list --format json | jq -r 'map(select(.recovery_addresses[].value | endswith("@ory.sh"))) | .[].id') | ||
|
||
I have to admit, this is not easy if you don't speak jq fluently. What about opening an issue and telling us what predefined selectors you want to have? https://github.com/ory/kratos/issues/new/choose | ||
|
||
|
||
``` | ||
kratos identities get <id-0 [id-1 ...]> [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for get | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
-e, --endpoint string The upstream admin endpoint URL. Alternatively set using the KRATOS_ADMIN_ENDPOINT environmental variable. | ||
-f, --format string Set the output format. One of table, json, and json-pretty. | ||
-q, --quiet Prints only IDs, one per line. Takes precedence over --format. | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kratos identities](kratos-identities) - Tools to interact with remote identities | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
id: kratos-identities-import | ||
title: kratos identities import | ||
description: kratos identities import Import identities from files or STD_IN | ||
--- | ||
|
||
<!-- | ||
This file is auto-generated. | ||
To improve this file please make your change against the appropriate "./cmd/*.go" file. | ||
--> | ||
## kratos identities import | ||
|
||
Import identities from files or STD_IN | ||
|
||
### Synopsis | ||
|
||
Import identities from files or STD_IN. Files are expected to each contain a single identity. The validity of files can be tested beforehand using `... identities validate`. | ||
|
||
``` | ||
kratos identities import <file.json [file-2.json [file-3.json] ...]> [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for import | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
-e, --endpoint string The upstream admin endpoint URL. Alternatively set using the KRATOS_ADMIN_ENDPOINT environmental variable. | ||
-f, --format string Set the output format. One of table, json, and json-pretty. | ||
-q, --quiet Prints only IDs, one per line. Takes precedence over --format. | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kratos identities](kratos-identities) - Tools to interact with remote identities | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
id: kratos-identities-list | ||
title: kratos identities list | ||
description: kratos identities list List identities | ||
--- | ||
|
||
<!-- | ||
This file is auto-generated. | ||
To improve this file please make your change against the appropriate "./cmd/*.go" file. | ||
--> | ||
## kratos identities list | ||
|
||
List identities | ||
|
||
### Synopsis | ||
|
||
List identities (paginated) | ||
|
||
``` | ||
kratos identities list [<page> <per-page>] [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for list | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
-e, --endpoint string The upstream admin endpoint URL. Alternatively set using the KRATOS_ADMIN_ENDPOINT environmental variable. | ||
-f, --format string Set the output format. One of table, json, and json-pretty. | ||
-q, --quiet Prints only IDs, one per line. Takes precedence over --format. | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kratos identities](kratos-identities) - Tools to interact with remote identities | ||
|
Oops, something went wrong.