Skip to content

Commit

Permalink
doc(model/write): add missing example to readme, correct help text ex…
Browse files Browse the repository at this point in the history
…ample (#295)
  • Loading branch information
rhamzeh authored Apr 18, 2024
2 parents cc62e25 + 604118f commit cbb24f3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ fga model **write**
* `--format`: Authorization model input format. Can be "fga", "json", or "modular". Defaults to the file extension if provided (optional)

###### Example
* `fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 --file model.fga`
* `fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 --file=model.fga`
* `fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 --file=fga.mod`
* `fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 '{"type_definitions": [ { "type": "user" }, { "type": "document", "relations": { "can_view": { "this": {} } }, "metadata": { "relations": { "can_view": { "directly_related_user_types": [ { "type": "user" } ] }}}} ], "schema_version": "1.1"}' --format json`

###### Response
Expand Down
5 changes: 3 additions & 2 deletions cmd/model/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ var writeCmd = &cobra.Command{
Short: "Write Authorization Model",
Long: "Writes a new authorization model.",
Example: `fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 --file=model.json
fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 '{"type_definitions":[{"type":"user"},{"type":"document","relations":{"can_view":{"this":{}}},"metadata":{"relations":{"can_view":{"directly_related_user_types":[{"type":"user"}]}}}}],"schema_version":"1.1"}'`, //nolint:lll
fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 --file=fga.mod
fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 '{"type_definitions":[{"type":"user"},{"type":"document","relations":{"can_view":{"this":{}}},"metadata":{"relations":{"can_view":{"directly_related_user_types":[{"type":"user"}]}}}}],"schema_version":"1.1"}' --format=json`, //nolint:lll
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientConfig := cmdutils.GetClientConfig(cmd)
Expand Down Expand Up @@ -97,7 +98,7 @@ var writeInputFormat = authorizationmodel.ModelFormatDefault
func init() {
writeCmd.Flags().String("store-id", "", "Store ID")
writeCmd.Flags().String("file", "", "File Name. The file should have the model in the JSON or DSL format")
writeCmd.Flags().Var(&writeInputFormat, "format", `Authorization model input format. Can be "fga" or "json"`)
writeCmd.Flags().Var(&writeInputFormat, "format", `Authorization model input format. Can be "fga", "json", or "modular"`) //nolint:lll

if err := writeCmd.MarkFlagRequired("store-id"); err != nil {
fmt.Printf("error setting flag as required - %v: %v\n", "cmd/models/write", err)
Expand Down
2 changes: 1 addition & 1 deletion internal/authorizationmodel/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ func (format *ModelFormat) Set(v string) error {
}

func (format *ModelFormat) Type() string {
return "ModelFormat"
return "format"
}

0 comments on commit cbb24f3

Please sign in to comment.