feat: add --indent flag to control line indentation in remind output

- Introduces an 'indent' integer flag to the CLI for specifying the
  number of spaces to indent lines in the remind output.
- Updates Task.ToRemind to accept an indent parameter and apply heading
  spaces accordingly.
- Adjusts main.go to pass the indent value from the flag to ToRemind.
This commit is contained in:
2026-01-15 00:05:34 +01:00
parent 1099f4ab97
commit 5e5999676d
2 changed files with 8 additions and 4 deletions

View File

@@ -26,7 +26,7 @@ type Task struct {
Metadata map[string][]string `json:"metadata"`
}
func (t Task) ToRemind() string {
func (t Task) ToRemind(indent int) string {
var sb strings.Builder
sb.WriteString("REM TODO ")
if t.DueDate == nil {
@@ -87,6 +87,8 @@ func (t Task) ToRemind() string {
sb.WriteString(" (%b)")
}
headingSpaces := strings.Repeat(" ", indent)
if len(t.Metadata) > 0 {
for k, values := range t.Metadata {
if k == "due" {
@@ -95,11 +97,11 @@ func (t Task) ToRemind() string {
// uppercase first letter for Remind
kUpper := strings.ToUpper(k[:1]) + k[1:]
if len(values) == 1 {
sb.WriteString(fmt.Sprintf("%%_%s: %%<%s>", kUpper, kUpper))
sb.WriteString(fmt.Sprintf("%%_%s%s: %%<%s>", headingSpaces, kUpper, kUpper))
} else {
for i := range values {
kNumbered := fmt.Sprintf("%s%d", kUpper, i+1)
sb.WriteString(fmt.Sprintf("%%_%s: %%<%s>", kNumbered, kNumbered))
sb.WriteString(fmt.Sprintf("%%_%s%s: %%<%s>", headingSpaces, kNumbered, kNumbered))
}
}
}