Commit
Author: Kevin Schoon [me@kevinschoon.com]
Hash: bbeaa8e38791707463ddd4a578a76c8653ee83a3
Timestamp: Mon, 23 May 2022 04:45:42 +0000 (2 years ago)

+109 -0 +/-6 browse
init
1diff --git a/.gitignore b/.gitignore
2new file mode 100644
3index 0000000..ba077a4
4--- /dev/null
5+++ b/.gitignore
6 @@ -0,0 +1 @@
7+ bin
8 diff --git a/Makefile b/Makefile
9new file mode 100644
10index 0000000..fdc1100
11--- /dev/null
12+++ b/Makefile
13 @@ -0,0 +1,10 @@
14+ .PHONY: bin/hierarchy
15+
16+ bin/hierarchy: bin
17+ hare build -o $@
18+
19+ bin:
20+ mkdir $@
21+
22+ clean:
23+ [[ -d bin ]] && rm -r bin
24 diff --git a/README.md b/README.md
25new file mode 100644
26index 0000000..551aabd
27--- /dev/null
28+++ b/README.md
29 @@ -0,0 +1,26 @@
30+ # Hierarchy
31+
32+ `hierarchy` is a hierarchical based note taking system for Linux. It is the
33+ successor to another project I worked on called [note](https://github.com/kevinschoon/note).
34+
35+ Hierarchy is written in [hare](https://harelang.org).
36+
37+ ## Usage
38+
39+ ```
40+ # list all notes
41+ hierarchy
42+ # create a new note
43+ hierarchy create hello
44+ # write the contents of a note to stdout
45+ hierarchy cat hello
46+ ```
47+
48+
49+ ## Building
50+
51+ ```
52+ make
53+ ```
54+
55+ ## Installation
56 diff --git a/config.ha b/config.ha
57new file mode 100644
58index 0000000..5f378f6
59--- /dev/null
60+++ b/config.ha
61 @@ -0,0 +1,32 @@
62+ use fmt;
63+ use dirs;
64+ use path;
65+
66+ // configuration file for hierarchy
67+ type config = struct {
68+ // base directory for storing notes
69+ base_dir: str,
70+ // editor for writing notes, if not specified it will try $EDITOR or
71+ // vim
72+ editor: str,
73+ };
74+
75+ fn default_config_path() str = {
76+ let base = dirs::config("hierarchy");
77+ return path::join(base, "config");
78+ };
79+
80+ fn default_data_path() str = {
81+ let base = dirs::data("hierarchy");
82+ return base;
83+ };
84+
85+ export fn load_config(path: str) config = {
86+ let default_path = default_config_path();
87+ fmt::println(default_path)!;
88+ let cfg = config {
89+ base_dir = "",
90+ editor = "vim"
91+ };
92+ return cfg;
93+ };
94 diff --git a/main.ha b/main.ha
95new file mode 100644
96index 0000000..d0da76f
97--- /dev/null
98+++ b/main.ha
99 @@ -0,0 +1,35 @@
100+ use fmt;
101+ use os;
102+ use getopt;
103+
104+ export fn main() void = {
105+ // Usage for sed
106+ const cmd = getopt::parse(os::args,
107+ "hierarchy",
108+ ('E', "use extended regular expressions"),
109+ ('s', "treat files as separate, rather than one continuous stream"),
110+ ('i', "edit files in place"),
111+ ('z', "separate lines by NUL characters"),
112+ ('e', "script", "execute commands from script"),
113+ ('f', "file", "execute commands from a file"),
114+ "files...",
115+ );
116+ defer getopt::finish(&cmd);
117+
118+ for (let i = 0z; i < len(cmd.opts); i += 1) {
119+ const opt = cmd.opts[i];
120+ switch (opt.0) {
121+ case 'E' =>
122+ fmt::println("heyya")!;
123+ case 's' =>
124+ fmt::println("heyya")!;
125+ };
126+ };
127+
128+ for (let i = 0z; i < len(cmd.args); i += 1) {
129+ const arg = cmd.args[i];
130+ // ...
131+ };
132+
133+ let cfg = load_config("nope");
134+ };
135 diff --git a/note.ha b/note.ha
136new file mode 100644
137index 0000000..ff92350
138--- /dev/null
139+++ b/note.ha
140 @@ -0,0 +1,5 @@
141+
142+ type note = struct {
143+ frontmatter: str,
144+ content: str
145+ };