29 lines
642 B
Go
29 lines
642 B
Go
|
|
package todo
|
||
|
|
|
||
|
|
import (
|
||
|
|
"os"
|
||
|
|
"path/filepath"
|
||
|
|
)
|
||
|
|
|
||
|
|
const todoRoot = "todo"
|
||
|
|
|
||
|
|
// Bootstrap creates the todo folder structure + basic index if missing.
|
||
|
|
func Bootstrap() error {
|
||
|
|
dirs := []string{
|
||
|
|
filepath.Join(todoRoot, "queued"),
|
||
|
|
filepath.Join(todoRoot, "doing"),
|
||
|
|
filepath.Join(todoRoot, "completed"),
|
||
|
|
}
|
||
|
|
for _, d := range dirs {
|
||
|
|
if err := os.MkdirAll(d, 0755); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// Basic index README stub
|
||
|
|
index := filepath.Join(todoRoot, "README.md")
|
||
|
|
if _, err := os.Stat(index); os.IsNotExist(err) {
|
||
|
|
return os.WriteFile(index, []byte("# Todo Index\n\n## Queued\n## Doing\n## Completed\n"), 0644)
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|