Skip to content

Commit 022f31a

Browse files
authored
docs: add examples to some commands (#572)
1 parent 2dad959 commit 022f31a

File tree

7 files changed

+127
-87
lines changed

7 files changed

+127
-87
lines changed

docs/zed.md

Lines changed: 99 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cmd/context.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ func registerContextCmd(rootCmd *cobra.Command) {
4040
}
4141

4242
contextRemoveCmd := &cobra.Command{
43-
Use: "remove <system>",
44-
Short: "Removes a context",
43+
Use: "remove <name>",
44+
Short: "Removes a context by name",
4545
Aliases: []string{"rm"},
4646
Args: commands.ValidationWrapper(cobra.ExactArgs(1)),
4747
ValidArgsFunction: ContextGet,
4848
RunE: contextRemoveCmdFunc,
4949
}
5050

5151
contextUseCmd := &cobra.Command{
52-
Use: "use <system>",
52+
Use: "use <name>",
5353
Short: "Sets a context as the current context",
5454
Args: commands.ValidationWrapper(cobra.MaximumNArgs(1)),
5555
ValidArgsFunction: ContextGet,

internal/commands/permission.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ func RegisterPermissionCmd(rootCmd *cobra.Command) *cobra.Command {
7777

7878
checkBulkCmd := &cobra.Command{
7979
Use: "bulk <resource:id#permission@subject:id> <resource:id#permission@subject:id> ...",
80-
Short: "Check permissions in bulk exist for resource-subject pairs",
80+
Short: "Check permissions in bulk exist for resource-permission-subject triplets",
8181
Args: ValidationWrapper(cobra.MinimumNArgs(1)),
8282
RunE: checkBulkCmdFunc,
8383
}
8484

8585
checkCmd := &cobra.Command{
8686
Use: "check <resource:id> <permission> <subject:id>",
87-
Short: "Check that a permission exists for a subject",
87+
Short: "Check if a subject has permission on a resource",
8888
Args: ValidationWrapper(cobra.ExactArgs(3)),
8989
ValidArgsFunction: GetArgs(ResourceID, Permission, SubjectID),
9090
RunE: checkCmdFunc,
@@ -100,15 +100,15 @@ func RegisterPermissionCmd(rootCmd *cobra.Command) *cobra.Command {
100100

101101
lookupResourcesCmd := &cobra.Command{
102102
Use: "lookup-resources <type> <permission> <subject:id>",
103-
Short: "Enumerates the resources of a given type for which the subject has permission",
103+
Short: "Enumerates the resources of a given type for which a subject has permission",
104104
Args: ValidationWrapper(cobra.ExactArgs(3)),
105105
ValidArgsFunction: GetArgs(ResourceType, Permission, SubjectID),
106106
RunE: lookupResourcesCmdFunc,
107107
}
108108

109109
lookupCmd := &cobra.Command{
110110
Use: "lookup <type> <permission> <subject:id>",
111-
Short: "Enumerates the resources of a given type for which the subject has permission",
111+
Short: "Enumerates the resources of a given type for which a subject has permission",
112112
Args: ValidationWrapper(cobra.ExactArgs(3)),
113113
ValidArgsFunction: GetArgs(ResourceType, Permission, SubjectID),
114114
RunE: lookupResourcesCmdFunc,

internal/commands/relationship.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ import (
2626
"github.com/authzed/zed/internal/console"
2727
)
2828

29-
const readCmdHelpLong = `Enumerates relationships matching the provided pattern.
30-
31-
To filter returned relationships using a resource ID prefix, append a '%' to the resource ID:
32-
33-
zed relationship read some-type:some-prefix-%
34-
`
35-
3629
func RegisterRelationshipCmd(rootCmd *cobra.Command) *cobra.Command {
3730
relationshipCmd := &cobra.Command{
3831
Use: "relationship <subcommand>",
@@ -45,6 +38,10 @@ func RegisterRelationshipCmd(rootCmd *cobra.Command) *cobra.Command {
4538
Args: ValidationWrapper(StdinOrExactArgs(3)),
4639
ValidArgsFunction: GetArgs(ResourceID, Permission, SubjectTypeWithOptionalRelation),
4740
RunE: writeRelationshipCmdFunc(v1.RelationshipUpdate_OPERATION_CREATE, os.Stdin),
41+
Example: `
42+
zed relationship create document:budget view user:anne --expiration-time "2025-12-31T23:59:59Z"
43+
zed relationship create document:budget view user:anne --caveat ip_address:'{"ip": "192.168.0.1"}
44+
`,
4845
}
4946

5047
touchCmd := &cobra.Command{
@@ -53,6 +50,10 @@ func RegisterRelationshipCmd(rootCmd *cobra.Command) *cobra.Command {
5350
Args: ValidationWrapper(StdinOrExactArgs(3)),
5451
ValidArgsFunction: GetArgs(ResourceID, Permission, SubjectTypeWithOptionalRelation),
5552
RunE: writeRelationshipCmdFunc(v1.RelationshipUpdate_OPERATION_TOUCH, os.Stdin),
53+
Example: `
54+
zed relationship touch document:budget view user:anne --expiration-time "2025-12-31T23:59:59Z"
55+
zed relationship touch document:budget view user:anne --caveat ip_address:'{"ip": "192.168.0.1"}
56+
`,
5657
}
5758

5859
deleteCmd := &cobra.Command{
@@ -66,10 +67,13 @@ func RegisterRelationshipCmd(rootCmd *cobra.Command) *cobra.Command {
6667
readCmd := &cobra.Command{
6768
Use: "read <resource_type:optional_resource_id> <optional_relation> <optional_subject_type:optional_subject_id#optional_subject_relation>",
6869
Short: "Enumerates relationships matching the provided pattern",
69-
Long: readCmdHelpLong,
7070
Args: ValidationWrapper(cobra.RangeArgs(1, 3)),
7171
ValidArgsFunction: GetArgs(ResourceID, Permission, SubjectTypeWithOptionalRelation),
7272
RunE: readRelationships,
73+
Example: `
74+
# To filter returned relationships using a resource ID prefix, append a '%' to the resource ID.
75+
zed relationship read document:finance-%
76+
`,
7377
}
7478

7579
bulkDeleteCmd := &cobra.Command{

internal/commands/relationship_nowasm.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !wasm
2-
// +build !wasm
32

43
package commands
54

0 commit comments

Comments
 (0)