ref: 12479fc71f58e704c755e626ae47e0f45f850995
parent: ab0fab2778501a8da79807db6820ea46ac9d72b1
author: Michael Misch <michaelmisch1985@gmail.com>
date: Thu Nov 28 06:35:53 PST 2019
Add samples dir to test various layouts
--- /dev/null
+++ b/.todo
@@ -1,0 +1,49 @@
+#1 TODO(halfwit): Create generate function
+
+[ ] generate.go: WalkFunc check for any match
+[ ] generate.go: Create each file
+
+#2 TODO(halfwit) #2 Create add function
+
+requires TODO(halfwit) #8
+
+[ ] add.go: Add link to dag
+
+#3 TODO(halfwit): Create rm function
+
+requires TODO(halfwit) #9
+
+[ ] rm.go: Remove link from dag
+
+#4 TODO(halfwit): Create dot function
+
+requires TODO(halfwit) #10
+[ ] list.go: Use dag libraries' built in dot printer
+
+#5 TODO(halfwit): Create list function
+
+requires TODO(halfwit) #10
+[ ] list.go: Print each leaf to stdout
+
+#6 TODO(halfwit): Create listAll function
+
+requires TODO(halfwit) #10
+[ ] list.go: Print each node to stdout
+
+#7 TODO(halfwit): Build graph function
+[ ] dag.go: Parse in .todo files
+[ ] dag.go: add edges/vertices into DAG
+
+#8 TODO(halfwit): add Subcommand
+[ ] add.go: AddChild
+[ ] add.go: AddParent
+
+#9 TODO(halfwit): rm Subcommands
+[ ] rm.go: RmChild
+[ ] rm.go: RmParent
+
+#10 TODO(halfwit): walk nodes
+[ ] list.go: Walk each node in the dag
+
+#11 TODO(halfwit): Write out to file
+[ ] write.go: Write out files with changes
--- /dev/null
+++ b/samples/.todo
@@ -1,0 +1,25 @@
+#1:
+TODO(halfwit) - Write all the code
+[ ] general: Show what things look like when added manually
+[ ] general: Show what auto generated looks like as well
+
+#2: requires [#1]
+TODO(halfwit) - remember how to write c code on normal systems
+[ ] sample.c: write the stuff
+[ ] sample.c: don't get hung up on the details
+
+#3: requires [#1]
+TODO(halfwit) - Make a demo of something interesting to demo `todo generate`
+[ ] sample.go: write the code
+[ ] sample.go: take the time
+
+#4: requires [#1] [example]
+TODO(halfwit) - Write some sample code
+[ ] sample.sh: get to the choppa
+[ ] sample.sh: return
+INFO - Show adding multiple components to a single task from other source files
+[x] file2.sh: Add another todo entry for the same tag
+
+example:
+[x] general: Show how headers are optional
+[x] general: Show something silly
\ No newline at end of file
--- /dev/null
+++ b/samples/file2.sh
@@ -1,0 +1,7 @@
+#!/bin/sh
+
+# INFO: [#4] Show adding multiple components to a single task from other source files
+# requires [#1] [example]
+# [x] Add another todo entry for the same tag
+
+echo "More stuff"
\ No newline at end of file
--- /dev/null
+++ b/samples/sample.c
@@ -1,0 +1,9 @@
+#include <stdio.h>
+
+int main(char argc, char **argv) {
+ // TODO (halfwit): [#2] remember how to write c code on normal systems
+ // requires [#1]
+ // [ ] write the stuff
+ // [ ] don't get hung up on the details
+ exit(0);
+}
\ No newline at end of file
--- /dev/null
+++ b/samples/sample.go
@@ -1,0 +1,8 @@
+package main
+
+func main() {
+ // TODO(halfwit): [#3] make a demo of something interesting to demo `todo generate`
+ // requires [#1]
+ // [ ] write the code
+ // [ ] take the time
+}
--- /dev/null
+++ b/samples/sample.sh
@@ -1,0 +1,8 @@
+#!/bin/sh
+
+# TODO(halfwit): [#4] Write some sample code
+# requires [#1]
+# [ ] get to the choppa
+# [ ] return
+
+echo "Had to write something here"
\ No newline at end of file
--- a/task.go
+++ b/task.go
@@ -6,9 +6,6 @@
"fmt"
"log"
"os"
- "path"
- "path/filepath"
- "strings"
"text/template"
)
@@ -19,7 +16,6 @@
type layout struct {
TaskList []*entries
- file string
}
// Entries - set of todo items for a give task
@@ -34,12 +30,11 @@
Done bool
}
-func parse(file string) (*layout, error) {
+func parse() (*layout, error) {
l := &layout{
TaskList: []*entries{},
- file: file,
}
- fl, err := os.Open(file)
+ fl, err := os.Open(".todo")
if err != nil {
return nil, err
}
@@ -90,39 +85,11 @@
}
}
-// We want to return any matched string for entry, otherwise return $dirname.todo of current directory
-func findEntry(entry string) string {
- wd, _ := os.Getwd()
- match := path.Base(wd) + ".todo"
-
- filepath.Walk(".", func(p string, info os.FileInfo, err error) error {
- if path.Ext(p) != ".todo" {
- return nil
- }
- // Found a file! Search for entry
- f, err := os.Open(p)
- if err != nil {
- return err
- }
- defer f.Close()
- scanner := bufio.NewScanner(f)
- for scanner.Scan() {
- if strings.Contains(scanner.Text(), entry) {
- match = p
- return filepath.SkipDir
- }
- }
- return nil
- })
- return match
-}
-
func task(c *command) error {
if len(c.args) < 2 {
return errors.New("Too few arguments supplied")
}
- fp := findEntry(c.args[1])
- l, err := parse(fp)
+ l, err := parse()
if err != nil && c.args[0] != "create" {
return err
}
@@ -131,7 +98,6 @@
case "create":
l = &layout{
TaskList: []*entries{},
- file: fp,
}
err = l.create(c.args[1])
if err != nil {
@@ -171,7 +137,7 @@
}
func (l *layout) destroy(title string) error {
- if _, err := os.Stat(l.file); err != nil {
+ if _, err := os.Stat(".todo"); err != nil {
return errors.New("Unable to locate .todo file")
}
for i, e := range l.TaskList {
@@ -199,7 +165,7 @@
}
func (l *layout) write() {
- wr, err := os.Create(l.file)
+ wr, err := os.Create(".todo")
defer wr.Close()
if err != nil {
log.Fatal(err)
--- a/todo2.todo
+++ /dev/null
@@ -1,27 +1,0 @@
-TODO(halfwit) Create generate function
-[ ] If flag for custom match file, parse in
-[ ] On find, use underlying task create
-[ ] WalkFunc check for any match
-
-TODO(halfwit) Create add function
-[ ] Subcommand parent/child/link
-[ ] Build graph
-[ ] Write out graph to file
-
-TODO(halfwit) Create rm function
-[ ] Subcommand parent/child/link
-[ ] Build graph
-[ ] Write out graph to file
-
-TODO(halfwit) Create dot function
-[ ] Build graph
-[ ] Convert to dot output
-
-TODO(halfwit) Create list function
-[ ] Build graph
-[ ] Write out graph leaves to stdout
-
-TODO(halfwit) Create listAll function
-[ ] Build graph
-[ ] Write out to stdout
-