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:
@@ -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" {
|
||||
@@ -99,7 +101,7 @@ func (t Task) ToRemind() string {
|
||||
} 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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user