diff --git a/README.md b/README.md index 11a455c..238a105 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,10 @@ The key `input_name` is a string and its value is a map of the input's configuration. The name can be used as an argument in the form `-` or `--` followed by a value. The input's value is a string. +### `commands..inputs..description` + +Optionally describe the input's purpose or outcome. + ### `commands..inputs..options` Limit the value to a list of acceptable values. Options can be a list of values diff --git a/config.go b/config.go index b3798ac..be1c844 100644 --- a/config.go +++ b/config.go @@ -39,6 +39,7 @@ type ConfigCommandInput struct { DefaultValue string `yaml:"default"` Pattern string Options ConfigCommandInputOptions + Description string } func (cci ConfigCommandInput) Selectable() bool { diff --git a/example/ilc.yml b/example/ilc.yml index f486029..bf1485f 100644 --- a/example/ilc.yml +++ b/example/ilc.yml @@ -31,6 +31,7 @@ commands: description: Give a greeting inputs: name: + description: A person's name default: World pattern: "^[a-zA-Z]+" greeting: diff --git a/help.go b/help.go index 030b75f..4bea1ca 100644 --- a/help.go +++ b/help.go @@ -27,7 +27,7 @@ var ( Width(14) helpDataListData = lipgloss.NewStyle() helpDefaultValue = lipgloss.NewStyle(). - Foreground(lipgloss.Color("51")) + Foreground(lipgloss.Color("8")) ) func printHelp(m *model) { @@ -120,10 +120,15 @@ func renderInputs(title string, inputs ConfigCommandInputs) string { items := make([]string, 0, inputsCount*2) for _, input := range inputs { - desc := "" + desc := input.Description if input.DefaultValue != "" { - desc = fmt.Sprintf("Default is %s", helpDefaultValue.Render(input.DefaultValue)) + defaultDesc := fmt.Sprintf("%s %s", helpDefaultValue.Render("Default is"), helpDefaultValue.Bold(true).Render(input.DefaultValue)) + if desc == "" { + desc = defaultDesc + } else { + desc = fmt.Sprintf("%s %s", desc, defaultDesc) + } } items = append(