Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
majori committed Nov 3, 2023
1 parent 164724c commit 876cc93
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
13 changes: 12 additions & 1 deletion cmd/docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func mapCommandInfos(cmds []*cobra.Command) []CommandInfo {
Name: f.Name,
Shorthand: f.Shorthand,
Default: f.DefValue,
Type: f.Value.Type(),
Type: valueTypeToString(f.Value),
Description: f.Usage,
})
})
Expand All @@ -88,3 +88,14 @@ func mapCommandInfos(cmds []*cobra.Command) []CommandInfo {

return infos
}

func valueTypeToString(v pflag.Value) string {
t := v.Type()
switch t {
case "stringArray":
return "[]string"
default:
return t
}

}
4 changes: 2 additions & 2 deletions cmd/docs/templates/schema.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| `sources` | `[]string` | | A list of URLs to source code for this recipe. |
| `initHelp` | `string` | | A message which will be showed to an user after a succesful recipe execution. Can be used to guide the user what should be done next in the project directory. |
| `ignorePatterns` | `[]string` | | Glob patterns for ignoring generated files from future recipe upgrades. Ignored files will not be regenerated even if their templates change in future versions of the recipe. |
| `vars` | `[]Variable` | | An array of variables which can be used in templates. |
| `vars` | [`[]Variable`](#variable) | | An array of variables which can be used in templates. |

### Variable

Expand All @@ -22,7 +22,7 @@
| `confirm` | `bool` | `false` | If set to true, the prompt will be yes/no question, and the value type will be boolean. |
| `optional` | `bool` | `false` | If set to true, the variable can be left empty. |
| `options` | `[]string` | | The user selects the value from a list of options. |
| `validators` | `[]Validator` | | Validators for the variable. |
| `validators` | [`[]Validator`](#validator) | | Validators for the variable. |
| `if` | `string` | | Makes the variable conditional based on the result of the expression. The result of the evaluation needs to be a boolean value. Uses https://github.com/antonmedv/expr. |
| `columns` | `[]string` | | Set the variable as a table type with columns defined by this property. |

Expand Down
2 changes: 1 addition & 1 deletion internal/cli/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewPullCmd() *cobra.Command {
var cmd = &cobra.Command{
Use: "pull URL",
Short: "Pull a recipe from OCI repository",
Long: "Pull a recipe from OCI repository and save it locally. You can authenticate by using the --username and --password flags or logging in first with `docker login`.",
Long: "Pull a recipe from OCI repository and save it locally. You can authenticate by using the `--username` and `--password` flags or logging in first with `docker login`.",
Args: cobra.ExactArgs(1),
PreRunE: func(cmd *cobra.Command, args []string) error {
opts.TargetRef = args[0]
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewPushCmd() *cobra.Command {
var cmd = &cobra.Command{
Use: "push RECIPE_PATH TARGET_URL",
Short: "Push a recipe to OCI repository",
Long: "Push a recipe to OCI repository (e.g. Docker registry). You can authenticate by using the --username and --password flags or logging in first with `docker login`.",
Long: "Push a recipe to OCI repository (e.g. Docker registry). You can authenticate by using the `--username` and `--password` flags or logging in first with `docker login`.",
Args: cobra.ExactArgs(2),
PreRunE: func(cmd *cobra.Command, args []string) error {
opts.RecipePath = args[0]
Expand Down
7 changes: 6 additions & 1 deletion internal/cli/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ func runUpgrade(cmd *cobra.Command, opts upgradeOptions) {
return
}

cmd.Printf("Upgrading recipe %s from version %s to %s\n", oldSauce.Recipe.Name, oldSauce.Recipe.Metadata.Version, re.Metadata.Version)
cmd.Printf(
"Upgrading recipe %s from version %s to %s\n",
oldSauce.Recipe.Name,
oldSauce.Recipe.Metadata.Version,
re.Metadata.Version,
)

// Check if the new version of the recipe has removed some variables
// which existed on previous version
Expand Down

0 comments on commit 876cc93

Please sign in to comment.