feat: initial parser for todo.txt format with spec and test cases
- Add parser for todo.txt tasks supporting priority, dates, projects, contexts, and key:value metadata - Include full todo.txt format specification (SPECS.md) and visual description (description.svg) - Add sample test.todo.txt file with valid, borderline, and malformed cases - Initialize Go module and main entrypoint for parsing and JSON output - Add .gitignore for binary artifacts
This commit is contained in:
31
main.go
Normal file
31
main.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.donadeo.net/pdonadeo/todotxt2remind/internal/parser"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Fprintf(os.Stderr, "usage: example /path/to/todo.txt\n")
|
||||
os.Exit(2)
|
||||
}
|
||||
f, err := os.Open(os.Args[1])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer func() { _ = f.Close() }()
|
||||
|
||||
tasks, errors := parser.ParseReader(f)
|
||||
if len(errors) > 0 {
|
||||
fmt.Fprintf(os.Stderr, "errors while parsing:\n")
|
||||
for _, e := range errors {
|
||||
fmt.Fprintf(os.Stderr, " - %v\n", e)
|
||||
}
|
||||
}
|
||||
b, _ := json.MarshalIndent(tasks, "", " ")
|
||||
fmt.Println(string(b))
|
||||
}
|
||||
Reference in New Issue
Block a user