Skip to content

Commit 3d7babd

Browse files
committed
Merge branch 'AppendHashtag'
2 parents 6dcffc9 + 5fa2e70 commit 3d7babd

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ The configuration file located in `.config/dly/dly.yml` in your home directory i
9090
| `DailyNotesPath` | yes | string | Path to the LogSeq daily notes (typically the `journal` folder in Logseq data directory)
9191
| `FilenameFormat` | yes | string | Format of your daily note, without the `.md` extension. The format follows (weird) Go formatting rules, see the [documentation](https://pkg.go.dev/time) or an [article](https://www.geeksforgeeks.org/time-formatting-in-golang/) for details. As a general rule, when you want to say "the current year" and expected something like `YYYY`, you use `2006` (yes, exactly this string). The "current month" is `01` and the "current day" is `02`. Yes this is insane. The default format (in the auto-generated file) is `2006_01_02` - this corresponds today to `2023_01_13` which in turns points to the file `2023_01_13.md`, which **Logseq** interprets as the date 2023-01-13.|
9292
| `AddTimestamp` | no | bool | Should your line be prefixed with a bolded timestamp? |
93-
| `AddHashtag` | no | bool | Should a tag be added at the end of your line? (usually to mark lines that were added though `dly`) |
94-
| `HashtagToAdd` | no | string | The hashtag to add, without `#` |
93+
| `AppendHashtag` | no | string | add the string as hashtag (example: `from-cli`, note the absence of `#` which will be automatically added) |
94+
| `AddHashtag`<br>(DEPRECATED) | no | bool | Should a tag be added at the end of your line? (usually to mark lines that were added though `dly`) |
95+
| `HashtagToAdd`<br>(DEPRECATED) | no | string | The hashtag to add, without `#` |
96+
97+
`AddHashtag` and `HashtagToAdd` are deprecated and will be removed in the next major version. having two parameters for a singe, simple feature does not make much sense.
9598

9699
## What next?
97100

dly.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import (
1818
type Configuration struct {
1919
DailyNotesPath string `yaml:"DailyNotesPath"`
2020
FilenameFormat string `yaml:"FilenameFormat"`
21-
AddTimestamp bool `yaml:"AddTimestamp,omitempty"`
21+
AddTimestamp bool `yaml:"AddTimestamp"`
22+
AppendHashtag string `yaml:"AppendHashtag"`
2223
AddHashtag bool `yaml:"AddHashtag,omitempty"`
2324
HashtagToAdd string `yaml:"HashtagToAdd,omitempty"`
2425
}
@@ -85,8 +86,14 @@ func addToTodayNote(note []byte, newText string, conf Configuration) (content []
8586
newText = fmt.Sprintf("**%s** %s", time.Now().Format("15:04"), newText)
8687
}
8788
// should we postfix it with an hashtag?
88-
if conf.AddHashtag {
89+
// check for the new parameter AppendHashtag
90+
if conf.AppendHashtag != "" {
91+
// new parameter
92+
newText = fmt.Sprintf("%s #%s", newText, conf.AppendHashtag)
93+
} else if conf.AddHashtag {
94+
// legacy, deprecated parameter
8995
newText = fmt.Sprintf("%s #%s", newText, conf.HashtagToAdd)
96+
log.Warn().Msgf("the configuration parameter AddHashtag is deprecated and will be removed in a future version. Use AppendHashtag instead")
9097
}
9198
// check if the note does not exist
9299
if len(note) == 0 {
@@ -219,8 +226,7 @@ func getConfiguration() (conf Configuration) {
219226
DailyNotesPath: "YOU MUST SET THIS to your journal folder",
220227
FilenameFormat: "2006_01_02",
221228
AddTimestamp: true,
222-
AddHashtag: true,
223-
HashtagToAdd: "from-cli",
229+
AppendHashtag: "from-cli",
224230
}
225231
defaultValuesB, _ := yaml.Marshal(defaultValues)
226232
_, err = f.Write(defaultValuesB)

0 commit comments

Comments
 (0)