From a2f2cd33c7b11226e3ecf1f012beb3da03fd138e Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 15 Jun 2021 09:21:54 -0400 Subject: [PATCH 01/40] Improve README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index dfbbef1..3169d38 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,15 @@ # `tree-query` +> This README is TODO. If you'd like to use this software in a project, **don't hestiate to reach out to me.** + Tree query is a tool that searches across indented lines. It is a replacement for Roam's query system. +## Command-line usage + +`tree-query '{and: [[Hello]] [[Hi]]}' file1 file2 folder1 folder2` + ## Features This section is a work-in-progress. From 62f3888b3b24aefdfb92aa0ecd55dd72256175a2 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 15 Jun 2021 09:58:27 -0400 Subject: [PATCH 02/40] Rename detect_indent_level to count_indents --- parser.d | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/parser.d b/parser.d index 192a2a4..68a5c2b 100644 --- a/parser.d +++ b/parser.d @@ -1,4 +1,4 @@ -/** Detect indent level and return where the indent level stops in "i" +/** Count the indent level and return where the indent level stops in "i" * A tab is counted as one indent. * Params: * i = the index to start looking from. This is mutated @@ -6,7 +6,7 @@ * was. * spaces_per_indent = the number of spaces to treat as one indent */ -int detect_indent_level(ref int i, string input, int spaces_per_indent=4) { +int count_indents(ref int i, string input, int spaces_per_indent=4) { int nspaces = 0; if (i == input.length || !(input[i] == ' ' || input[i] == '\t')) { return 0; @@ -26,10 +26,10 @@ int detect_indent_level(ref int i, string input, int spaces_per_indent=4) { } unittest { int i; - assert(detect_indent_level(i = 0, " - hi") == 1); - assert(detect_indent_level(i = 0, "Foo") == 0); - assert(detect_indent_level(i = 0, " - hi") == 2); - assert(detect_indent_level(i = 0, "\t - hey") == 1); + assert(count_indents(i = 0, " - hi") == 1); + assert(count_indents(i = 0, "Foo") == 0); + assert(count_indents(i = 0, " - hi") == 2); + assert(count_indents(i = 0, "\t - hey") == 1); } void doNothing(T)(T _=null) {} /** A streaming parser for Markdown trees. Emits a stream of parsing events. @@ -86,7 +86,7 @@ void parse(ParseEventHandler, i++; line_start_index = i; int new_indent_level = - detect_indent_level(i, input, spaces_per_indent); + count_indents(i, input, spaces_per_indent); line_content_start_index = i; const extraEndings = i == input.length ? 0 : 1; foreach (_; From 9020753f0edffeac060f5da8fb95d450b4395cf3 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 15 Jun 2021 10:00:52 -0400 Subject: [PATCH 03/40] Improve documentation --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 3169d38..6ab6d02 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,10 @@ Tree-query is written in [Dlang](https://dlang.org) but don't let that put you o If you have any questions on D, feel free to go to #d on freenode or D Forums. People are very nice. +### Internals + +I've spent some time writing doc comments inside the code. They provide a conceptual explanation of how the system works. Look for `/**` and `/++`. + ### Notes A string in D is a reference to a region of immutable memory. It is a length and a pointer. For this reason, it is is very efficient to copy. From 6cdcc3ef340ec056417294dc23b5a31a48c3f3f9 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 15 Jun 2021 10:04:17 -0400 Subject: [PATCH 04/40] Note the detail level of the docs --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6ab6d02..6929b68 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ If you have any questions on D, feel free to go to #d on freenode or D Forums. P I've spent some time writing doc comments inside the code. They provide a conceptual explanation of how the system works. Look for `/**` and `/++`. +Inside the unittests, there's an example guide on using `parser.d` as a library to build a Markdown to XML converter. + ### Notes A string in D is a reference to a region of immutable memory. It is a length and a pointer. For this reason, it is is very efficient to copy. From 66d5534e4cb30beb463f95378d42ff7604bf92cf Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 15 Jun 2021 10:50:25 -0400 Subject: [PATCH 05/40] Fix inaccuracy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6929b68..1a0c319 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ It is a replacement for Roam's query system. This section is a work-in-progress. -* **Fast**: Over 880Gbps on a MacBook Air +* **Fast**: Over 880Mbps on a MacBook Air ## Contributing From 67866ba17053986cbdc9e67d0c2f7d6147978af6 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 16 Jun 2021 13:50:40 -0400 Subject: [PATCH 06/40] Add quickstart and improve description --- README.md | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1a0c319..818d4ad 100644 --- a/README.md +++ b/README.md @@ -4,17 +4,40 @@ Tree query is a tool that searches across indented lines. -It is a replacement for Roam's query system. +It is a replacement for Roam's query system. It supports everything Roam does, except for block references. -## Command-line usage +## Quickstart -`tree-query '{and: [[Hello]] [[Hi]]}' file1 file2 folder1 folder2` +**Query in current directory:** +``` +tree-query '{and: [[Page 1]] [[Page 2]]}' . +``` +[*Learn to navigate to a working directory with `cd`*](https://linuxize.com/post/linux-cd-command/) + +**Query in a folder:** + +``` +tree-query '{and: [[Page 1]] [[Page 2]]}' /Users/steve/myfoldername/ +``` +*Learn to get the location of a folder on [macOS](https://osxdaily.com/2009/11/23/copy-a-files-path-to-the-terminal-by-dragging-and-dropping/), [Windows](https://www.top-password.com/blog/copy-full-path-of-a-folder-file-in-windows/), or [GNU+Linux](https://unix.stackexchange.com/questions/102551/mouse-shortcut-to-copy-the-path-to-a-file-in-the-gnome-file-manager).* + +**Query in a group of folders and files:** + +``` +tree-query '{and: [[Page 1]] [[Page 2]]}' /Users/steve/myfoldername/ file1 +``` + +**Query stdin:** + +``` +cat myfile | tree-query '{and: [[Page 1]] [[Page 2]]}' +``` ## Features This section is a work-in-progress. -* **Fast**: Over 880Mbps on a MacBook Air +* **Fast** ## Contributing From 3a930fb74fbac3c93abb448f37fdc6723a657418 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 16 Jun 2021 13:53:53 -0400 Subject: [PATCH 07/40] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 818d4ad..3ebbbe2 100644 --- a/README.md +++ b/README.md @@ -15,23 +15,22 @@ tree-query '{and: [[Page 1]] [[Page 2]]}' . [*Learn to navigate to a working directory with `cd`*](https://linuxize.com/post/linux-cd-command/) **Query in a folder:** - ``` tree-query '{and: [[Page 1]] [[Page 2]]}' /Users/steve/myfoldername/ ``` *Learn to get the location of a folder on [macOS](https://osxdaily.com/2009/11/23/copy-a-files-path-to-the-terminal-by-dragging-and-dropping/), [Windows](https://www.top-password.com/blog/copy-full-path-of-a-folder-file-in-windows/), or [GNU+Linux](https://unix.stackexchange.com/questions/102551/mouse-shortcut-to-copy-the-path-to-a-file-in-the-gnome-file-manager).* -**Query in a group of folders and files:** +Or query in multiple folders and files: ``` tree-query '{and: [[Page 1]] [[Page 2]]}' /Users/steve/myfoldername/ file1 ``` -**Query stdin:** - +**Query stdin with pipes:** ``` cat myfile | tree-query '{and: [[Page 1]] [[Page 2]]}' ``` +[*Learn to build powerful no-code applications using pipes*](https://youtu.be/tc4ROCJYbm0?t=360) ## Features From d9e20c7b6ad9a60f790c7ead97e4c5c9736070f1 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 16 Jun 2021 14:02:20 -0400 Subject: [PATCH 08/40] Add basic usage section --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 3ebbbe2..9abffc6 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,19 @@ This section is a work-in-progress. * **Fast** +## Basic usage with the command-line + +### Copy result to clipboard +macOS: +``` +tree-query '{and: [[Page 1]] [[Page 2]]}' . | pbcopy +``` + +GNU+Linux: +``` +tree-query '{and: [[Page 1]] [[Page 2]]}' . | +``` + ## Contributing Tree-query is written in [Dlang](https://dlang.org) but don't let that put you off- if you know C, C++, or Java, you'll pick it up very quickly. From fcd430a246ccf332fae43877b95585512cdb691f Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 16 Jun 2021 14:03:14 -0400 Subject: [PATCH 09/40] Add query.d --- query.d | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 query.d diff --git a/query.d b/query.d new file mode 100644 index 0000000..dfe341c --- /dev/null +++ b/query.d @@ -0,0 +1,92 @@ +/++ Query system that implements Roam queries. +/ +module query; +import interp; +debug import std.stdio; + +// Unoptimized function to calculate matches for a set of +// words +// This should be replaced by something faster. +// For instance, a regex library, that scans once, instead of once +struct DumbMatcher(BitType) { + string[] search_terms; + this(string[] terms) { + search_terms = terms; + } + BitType match(string str) { + import std.algorithm.searching : canFind; + BitType result; + debug writeln("Query " ~ str); + for (int i = 0; i < search_terms.length; ++i) { + auto term = search_terms[i]; + if (canFind(str, term)) { + debug writeln("Matched with " ~ term); + result |= 1 << i; + } + } + return result; + } + unittest { + DumbMatcher!BitType matcher = DumbMatcher(["red", "green"]); + assert(matcher.match("blue") == 0b00); + assert(matcher.match("red") == 0b01); + assert(matcher.match("green") == 0b10); + assert(matcher.match("red green") == 0b11); + assert(matcher.match("blue green") == 0b10); + Form form = { Op.ATOM, bitshift: 0}; + assert(eval_form(matcher.match("red"), Form(Op.AND, [form]))); + } + unittest { + DumbMatcher!BitType matcher = DumbMatcher(["[[PRIME Theory]]", "[[PRIME: Motives]]"]); + assert(matcher.match("- In every moment we [act]([[PRIME: Responses]]) in pursuit of what we most [want or need]([[PRIME: Motives]]) at that moment. Something can only exert [[behavioral influence]] if it is [[salient]] at the moment") == 0b10); + } +} +struct RegexMatcher; +struct TrieMatcher; + +alias BitType = uint; + +/++Roam query. + + It handles a stream of START and END events. + + START means a indented block or line started + + END means a indented block or line ended + + + + It computes a bitfield for each line. + + Each bit in the bitfield corresponds to a word in the query, and represents + + whether that bit was present in this line or one of its parents. + +/ +struct QueryHandler { + bool matching = false; + string[] parent_lines; // Bookkeeping data structure. Holds parent lines as strings, so we can later print them out. + //string[] to_print; + BitType[] bit_stack = [0]; + DumbMatcher!BitType matcher; + Form expression; + this(string[] terms, Form form) { // Construct a QueryHandler struct + debug writeln("Terms", terms); + assert(terms.length < BitType.sizeof * 8); + matcher = DumbMatcher!BitType(terms); + expression = form; + } + void start(string line) { + BitType own_bits = matcher.match(line); + bit_stack ~= bit_stack[$-1] | own_bits; + debug writeln("Own bitstring", own_bits); + parent_lines ~= line; + if (eval_form(bit_stack[$-1], expression)) { + import std.stdio; + foreach (parent_line; parent_lines) + writeln(parent_line); + // Simple way to avoid printing it twice + parent_lines.length = 0; + } + } + void end() { + debug writeln("stacklen", bit_stack.length); + bit_stack.length--; + if (parent_lines.length > 0) + parent_lines = parent_lines[0..$-1]; // Pop the last item + } +} +unittest { + //QueryHandler!uint handler = QueryHandler!uint(["red", "green"], ""); +} From bab6c5fcc99531a89fde9f6b12d1c01f80aa9a77 Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 16 Jun 2021 14:06:30 -0400 Subject: [PATCH 10/40] Add boolean expression evaluator --- interp.d | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 interp.d diff --git a/interp.d b/interp.d new file mode 100644 index 0000000..c87a29a --- /dev/null +++ b/interp.d @@ -0,0 +1,63 @@ +/+ A boolean expression interpreter. + + Used to evaluate boolean bitfields for the query. + +/ +module interp; + +import std.variant; +import std.typecons; +// TCO +alias BitType = uint; +enum Op { AND, OR, NOT, ATOM }; +bool eval_form(BitType bitstring, Form form) { + if (form.op == Op.AND) { + return eval_and(bitstring, form.operands); + } else if (form.op == Op.OR) { + return eval_or(bitstring, form.operands); + } else if (form.op == Op.NOT) { + return cast(bool)(!(bitstring & (1 << form.operands[0].bitshift))); + //return cast(bool)(!(bitstring & (1 << form.bitshift))); + } else { + return cast(bool)(bitstring & (1 << form.bitshift)); + } +} +struct Form { + Op op; + union { + Form[] operands; + // What is faster, a ubyte or a byte? + ubyte bitshift; + } +} +bool eval_and(BitType bitstring, Form[] terms) { + if (terms.length == 0) { + return true; + } + if (eval_form(bitstring, terms[0])) { + return eval_and(bitstring, terms[1..$]); + } else { + // short-circuit evaluation + return false; + } +} +bool eval_or(BitType bitstring, Form[] terms) { + if (terms.length == 0) { + return false; + } + if (eval_form(bitstring, terms[0])) { + // short-circuit evaluation + return true; + } else { + return eval_or(bitstring, terms[1..$]); + } +} +private Form Atom(ubyte bitshift) { + Form form = { Op.ATOM, bitshift: bitshift }; + return form; +} +unittest { + assert(eval_form(0b1, Form(Op.OR, [Atom(0)])) == true); + assert(eval_form(0b11, Form(Op.AND, [Atom(0), Atom(1)])) == true); + assert(eval_form(0b10, Form(Op.AND, [Atom(0), Atom(1)])) == false); + assert(eval_form(0b10, Form(Op.OR , [Atom(0), Atom(1)])) == true); + assert(eval_form(0b111,Form(Op.AND, [Form(Op.AND, [Atom(0), Atom(2)]), Atom(1)])) == true); +} From a0941f9c336e135998d302986d9081280d35947c Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 16 Jun 2021 14:19:38 -0400 Subject: [PATCH 11/40] Add support for {query: --- tree-query.d | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tree-query.d b/tree-query.d index a512602..2b47666 100644 --- a/tree-query.d +++ b/tree-query.d @@ -39,7 +39,12 @@ string extractQuery(string query) { } } unittest { - const nakedQueries = ["{and: [[foo]] [[bar]] }", "{or: [[foo]] [[bar]] }"]; + const nakedQueries = [ + "{and: [[foo]] [[bar]] }", + "{or: [[foo]] [[bar]] }", + "{and: [[foo]] [[bar]]}", + "{and: [[foo]] {and: [[bar]] [[spam]]}}" + ]; foreach (nakedQuery; nakedQueries) { assert(extractQuery(nakedQuery) == nakedQuery); assert(extractQuery("{{query:" ~ nakedQuery ~ "}}") == nakedQuery); @@ -156,7 +161,7 @@ int main(string[] args) { // Read query immediately. If the user has written an invalid query, show // an error before we read in all files. ubyte n = 0; - ParsedQuery qu = booleanQuery(query, n); + ParsedQuery qu = booleanQuery(extractQuery(query), n); string[] inputs; string[] inputnames; if (args.length == 0) { From d909352689eaa6ee5a098e862849ba06e6f0af9a Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 16 Jun 2021 14:20:35 -0400 Subject: [PATCH 12/40] Show error message when executed without a query --- tree-query.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tree-query.d b/tree-query.d index 2b47666..2d761d9 100644 --- a/tree-query.d +++ b/tree-query.d @@ -152,7 +152,7 @@ int main(string[] args) { import std.getopt, std.file, std.stdio; // Parse arguments string query; - if (args[1].strip.startsWith("{")) { + if (args.length >= 2 && args[1].strip.startsWith("{")) { query = args[1]; args = args[2..$]; } else { From 9b4603811213bb8e0576922d4a342d3285652a6c Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 16 Jun 2021 14:26:21 -0400 Subject: [PATCH 13/40] Add release notes --- RELEASE_NOTES.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 RELEASE_NOTES.md diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md new file mode 100644 index 0000000..d19e769 --- /dev/null +++ b/RELEASE_NOTES.md @@ -0,0 +1,14 @@ +# Release notes + +## Since 0.0.1 + - Added hyperlinked documentation on usage instructions for people new to the CLI + - Added missing source files, now it's possible to compile + - Support for starting queries with `{query:` was enabled + - Shows message when executed without a query + +## 0.0.1 + - Supports `{and:`, `{or:`, `{not:`, nested arbitrarily, querying using page references + - Works on any kind of indentation, including tabs, spaces. + - Caveat: Mixing tabs and spaces in one file may lead to undesired results, because a tab is interpreted as one space + - Ignores text inside Markdown code blocks `\`\`\`` + - Indentation is different for these code blocks. Searching with their text included as part of the parent block is not supported yet From e024e09ddce2dab8c807cece29dd57c869d52d3b Mon Sep 17 00:00:00 2001 From: James Date: Wed, 16 Jun 2021 14:30:23 -0400 Subject: [PATCH 14/40] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d19e769..d5bcd63 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -10,5 +10,5 @@ - Supports `{and:`, `{or:`, `{not:`, nested arbitrarily, querying using page references - Works on any kind of indentation, including tabs, spaces. - Caveat: Mixing tabs and spaces in one file may lead to undesired results, because a tab is interpreted as one space - - Ignores text inside Markdown code blocks `\`\`\`` + - Ignores text inside Markdown code blocks - Indentation is different for these code blocks. Searching with their text included as part of the parent block is not supported yet From 15b63956dacfecebdfd90031332ec63ef4d734b5 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 16 Jun 2021 14:55:26 -0400 Subject: [PATCH 15/40] Fix copy result to clipboard for GNU+Linux --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9abffc6..2706ecd 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ tree-query '{and: [[Page 1]] [[Page 2]]}' . | pbcopy GNU+Linux: ``` -tree-query '{and: [[Page 1]] [[Page 2]]}' . | +tree-query '{and: [[Page 1]] [[Page 2]]}' . | xclip ``` ## Contributing From fbb78e3810c90049ed6b3bc5adfe5d7e8a62e2f1 Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 16 Jun 2021 17:36:09 -0400 Subject: [PATCH 16/40] Explain the different build kinds --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index da286b6..130d0ef 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,13 @@ .PHONY = md2sexpr-build +# Compile a debug build for quick development tree-query: tree-query.d interp.d query.d parser.d dmd -g -debug -check=invariant -unittest tree-query.d interp.d query.d parser.d md2sexpr-build: ~/dlang/ldc-1.23.0/bin/ldc2 --link-defaultlib-shared=false -O3 -release md2sexpr.d parser.d +# Compile with LLVM tree-query-build: ~/dlang/ldc-1.23.0/bin/ldc2 --link-defaultlib-shared=false -O2 -release tree-query.d interp.d query.d parser.d strip tree-query From 921d3abd210923aa28388718b6af89c6406ec868 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 17 Jun 2021 18:33:11 -0400 Subject: [PATCH 17/40] Add experimental build from source instructions --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index 2706ecd..cfe7803 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,39 @@ Tree query is a tool that searches across indented lines. It is a replacement for Roam's query system. It supports everything Roam does, except for block references. +## Installation + +### Build from source +Currently the only supported method. DYI style. + +On FreeBSD, GNU+Linux, and macOS, open Terminal and go: +``` +curl https://dlang.org/install.sh | bash -s +``` + +On Windows, download and install [Git Bash](https://gitforwindows.org/): +``` +mkdir %USERPROFILE%\dlang +powershell.exe -Command "wget https://dlang.org/install.sh -OutFile %USERPROFILE%\dlang\install.sh" +``` + +Then: + +``` +~/dlang/install.sh install ldc-1.23.0,dub +``` + +Then `cd` into the directory where you cloned this directory and type: +``` +make tree-query-build +``` + +Install to make available eveywhere: +``` +chmod 700 ~/Downloads/tree-query +sudo mv ~/Downloads/tree-query /usr/local/bin +``` + ## Quickstart **Query in current directory:** From 000f2b0c65822ea467a121ca8142b90631a6dd16 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 17 Jun 2021 18:35:13 -0400 Subject: [PATCH 18/40] Move installation section, copyedit --- README.md | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index cfe7803..ec0f0c7 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,32 @@ Tree query is a tool that searches across indented lines. It is a replacement for Roam's query system. It supports everything Roam does, except for block references. +## Quickstart + +**Query in current directory:** +``` +tree-query '{and: [[Page 1]] [[Page 2]]}' . +``` +[*Learn to navigate to a working directory with `cd`*](https://linuxize.com/post/linux-cd-command/) + +**Query in a folder:** +``` +tree-query '{and: [[Page 1]] [[Page 2]]}' /Users/steve/myfoldername/ +``` +*Learn to get the location of a folder on [macOS](https://osxdaily.com/2009/11/23/copy-a-files-path-to-the-terminal-by-dragging-and-dropping/), [Windows](https://www.top-password.com/blog/copy-full-path-of-a-folder-file-in-windows/), or [GNU+Linux](https://unix.stackexchange.com/questions/102551/mouse-shortcut-to-copy-the-path-to-a-file-in-the-gnome-file-manager).* + +Or query in multiple folders and files: + +``` +tree-query '{and: [[Page 1]] [[Page 2]]}' /Users/steve/myfoldername/ file1 +``` + +**Query stdin with pipes:** +``` +cat myfile | tree-query '{and: [[Page 1]] [[Page 2]]}' +``` +[*Learn to build powerful no-code applications using pipes*](https://youtu.be/tc4ROCJYbm0?t=360) + ## Installation ### Build from source @@ -16,7 +42,7 @@ On FreeBSD, GNU+Linux, and macOS, open Terminal and go: curl https://dlang.org/install.sh | bash -s ``` -On Windows, download and install [Git Bash](https://gitforwindows.org/): +On Windows, download and install [Git Bash](https://gitforwindows.org/), then run: ``` mkdir %USERPROFILE%\dlang powershell.exe -Command "wget https://dlang.org/install.sh -OutFile %USERPROFILE%\dlang\install.sh" @@ -39,32 +65,6 @@ chmod 700 ~/Downloads/tree-query sudo mv ~/Downloads/tree-query /usr/local/bin ``` -## Quickstart - -**Query in current directory:** -``` -tree-query '{and: [[Page 1]] [[Page 2]]}' . -``` -[*Learn to navigate to a working directory with `cd`*](https://linuxize.com/post/linux-cd-command/) - -**Query in a folder:** -``` -tree-query '{and: [[Page 1]] [[Page 2]]}' /Users/steve/myfoldername/ -``` -*Learn to get the location of a folder on [macOS](https://osxdaily.com/2009/11/23/copy-a-files-path-to-the-terminal-by-dragging-and-dropping/), [Windows](https://www.top-password.com/blog/copy-full-path-of-a-folder-file-in-windows/), or [GNU+Linux](https://unix.stackexchange.com/questions/102551/mouse-shortcut-to-copy-the-path-to-a-file-in-the-gnome-file-manager).* - -Or query in multiple folders and files: - -``` -tree-query '{and: [[Page 1]] [[Page 2]]}' /Users/steve/myfoldername/ file1 -``` - -**Query stdin with pipes:** -``` -cat myfile | tree-query '{and: [[Page 1]] [[Page 2]]}' -``` -[*Learn to build powerful no-code applications using pipes*](https://youtu.be/tc4ROCJYbm0?t=360) - ## Features This section is a work-in-progress. From 854acfed6599b4a589fd6608fa4bbc06696ebf8a Mon Sep 17 00:00:00 2001 From: James Date: Thu, 17 Jun 2021 18:37:41 -0400 Subject: [PATCH 19/40] Clarify mixing tabs issue --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ec0f0c7..5e23db6 100644 --- a/README.md +++ b/README.md @@ -103,4 +103,4 @@ A string in D is a reference to a region of immutable memory. It is a length and A struct is like a Java record or class. ## Known bugs - - Mixing tabs and spaces is not supported, unless an explicit spaces per indent specified + - Mixing tabs and spaces is not supported in the same file, unless an explicit spaces per indent specified From e7f1f2d3ce19ea0095c0fe6104f7af9582f9a21a Mon Sep 17 00:00:00 2001 From: James Date: Thu, 17 Jun 2021 18:43:08 -0400 Subject: [PATCH 20/40] Add GNU Kind Communication Guidelines as CoC --- CODE_OF_CONDUCT.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..a20bea7 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,31 @@ +# GNU Kind Communications Guidelines + +by Richard Stallman +## Purpose + +The GNU Project encourages contributions from anyone who wishes to advance the development of the GNU system, regardless of gender, race, ethnic group, physical appearance, religion, cultural background, and any other demographic characteristics, as well as personal political views. + +People are sometimes discouraged from participating in GNU development because of certain patterns of communication that strike them as unfriendly, unwelcoming, rejecting, or harsh. This discouragement particularly affects members of disprivileged demographics, but it is not limited to them. Therefore, we ask all contributors to make a conscious effort, in GNU Project discussions, to communicate in ways that avoid that outcome—to avoid practices that will predictably and unnecessarily risk putting some contributors off. + +These guidelines suggest specific ways to accomplish that goal. + +## Guidelines + +- Please assume other participants are posting in good faith, even if you disagree with what they say. When people present code or text as their own work, please accept it as their work. Please do not criticize people for wrongs that you only speculate they may have done; stick to what they actually say and actually do. +- Please think about how to treat other participants with respect, especially when you disagree with them. For instance, call them by the names they use, and honor their preferences about their gender identity[1]. +- Please do not take a harsh tone towards other participants, and especially don't make personal attacks against them. Go out of your way to show that you are criticizing a statement, not a person. +- Please recognize that criticism of your statements is not a personal attack on you. If you feel that someone has attacked you, or offended your personal dignity, please don't “hit back” with another personal attack. That tends to start a vicious circle of escalating verbal aggression. A private response, politely stating your feelings as feelings, and asking for peace, may calm things down. Write it, set it aside for hours or a day, revise it to remove the anger, and only then send it. +- Please avoid statements about the presumed typical desires, capabilities or actions of some demographic group. They can offend people in that group, and they are always off-topic in GNU Project discussions. +- Please be especially kind to other contributors when saying they made a mistake. Programming means making lots of mistakes, and we all do so—this is why regression tests are useful. Conscientious programmers make mistakes, and then fix them. It is helpful to show contributors that being imperfect is normal, so we don't hold it against them, and that we appreciate their imperfect contributions though we hope they follow through by fixing any problems in them. +- Likewise, be kind when pointing out to other contributors that they should stop using certain nonfree software. For their own sake, they ought to free themselves, but we welcome their contributions to our software packages even if they don't do that. So these reminders should be gentle and not too frequent—don't nag. +- By contrast, to suggest that others run a nonfree program opposes the basic principles of GNU, so it is not allowed in GNU Project discussions. +- Please respond to what people actually said, not to exaggerations of their views. Your criticism will not be constructive if it is aimed at a target other than their real views. +- If in a discussion someone brings up a tangent to the topic at hand, please keep the discussion on track by focusing on the current topic rather than the tangent. This is not to say that the tangent is bad, or not interesting to discuss—only that it shouldn't interfere with discussion of the issue at hand. In most cases, it is also off-topic, so those interested ought to discuss it somewhere else. +- If you think the tangent is an important and pertinent issue, please bring it up as a separate discussion, with a Subject field to fit, and consider waiting for the end of the current discussion. +- Rather than trying to have the last word, look for the times when there is no need to reply, perhaps because you already made the relevant point clear enough. If you know something about the game of Go, this analogy might clarify that: when the other player's move is not strong enough to require a direct response, it is advantageous to give it none and instead move elsewhere. +- Please don't argue unceasingly for your preferred course of action when a decision for some other course has already been made. That tends to block the activity's progress. +- If others have irritated you, perhaps by disregarding these guidelines, please don't excoriate them, and especially please don't hold a grudge against them. The constructive approach is to encourage and help other people to do better. When they are trying to learn to do better, please give them plenty of chances. +- If other participants complain about the way you express your ideas, please make an effort to cater to them. You can find ways to express the same points while making others more comfortable. You are more likely to persuade others if you don't arouse ire about secondary things. +- Please don't raise unrelated political issues in GNU Project discussions, because they are off-topic. The only political positions that the GNU Project endorses are (1) that users should have control of their own computing (for instance, through free software) and (2) supporting basic human rights in computing. We don't require you as a contributor to agree with these two points, but you do need to accept that our decisions will be based on them. + +By making an effort to follow these guidelines, we will encourage more contribution to our projects, and our discussions will be friendlier and reach conclusions more easily. From e705d685f814b319a3c84b54cdac29e4f9f37590 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 17 Jun 2021 19:06:16 -0400 Subject: [PATCH 21/40] Add basic build (windows, macos todo) --- .github/workflows/make.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/make.yml diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml new file mode 100644 index 0000000..67ebc6a --- /dev/null +++ b/.github/workflows/make.yml @@ -0,0 +1,22 @@ +name: Makefile CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: dlang-community/setup-dlang@4c99aa991ce7d19dd3064de0a4f2f6b2f152e2d7 + - name: make tree-query + run: make + - name: make tree-query-build + run: make tree-query-build + - name: make distcheck + run: make distcheck From 65147fc771a73343c03ba1b5b3874cb405a042c5 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 17 Jun 2021 19:10:46 -0400 Subject: [PATCH 22/40] Compile with ldc2 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 130d0ef..67efc18 100644 --- a/Makefile +++ b/Makefile @@ -9,5 +9,5 @@ md2sexpr-build: # Compile with LLVM tree-query-build: - ~/dlang/ldc-1.23.0/bin/ldc2 --link-defaultlib-shared=false -O2 -release tree-query.d interp.d query.d parser.d + ldc2 --link-defaultlib-shared=false -O2 -release tree-query.d interp.d query.d parser.d strip tree-query From e098b8e75e5a009207296b48cd290ca0d73d4011 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 17 Jun 2021 19:13:49 -0400 Subject: [PATCH 23/40] Fix Makefile CI --- .github/workflows/make.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index 67ebc6a..8865293 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -8,12 +8,20 @@ on: jobs: build: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + dc: [dmd-latest, ldc-latest, dmd-2.085.0, ldc-1.17.0] + exclude: + - { os: macOS-latest, dc: dmd-2.085.0 } - runs-on: ubuntu-latest - + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - - uses: dlang-community/setup-dlang@4c99aa991ce7d19dd3064de0a4f2f6b2f152e2d7 + - name: Install D compiler + uses: dlang-community/setup-dlang@v1 + with: + compiler: ${{ matrix.dc }} - name: make tree-query run: make - name: make tree-query-build From e4ff88d745e5916d40d194b170fee0ea8809a8de Mon Sep 17 00:00:00 2001 From: James Date: Thu, 17 Jun 2021 19:18:46 -0400 Subject: [PATCH 24/40] Update make.yml --- .github/workflows/make.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index 8865293..df54ea9 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -23,8 +23,8 @@ jobs: with: compiler: ${{ matrix.dc }} - name: make tree-query - run: make + run: (dmd && make) || true - name: make tree-query-build - run: make tree-query-build + run: (ldc && make tree-query-build) || true - name: make distcheck run: make distcheck From 1cb46bc9dc46e52fc6177a19f4581723a04ff391 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 17 Jun 2021 19:19:31 -0400 Subject: [PATCH 25/40] Update make.yml --- .github/workflows/make.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index df54ea9..71f68c6 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -26,5 +26,5 @@ jobs: run: (dmd && make) || true - name: make tree-query-build run: (ldc && make tree-query-build) || true - - name: make distcheck - run: make distcheck + #- name: make distcheck + # run: make distcheck From 0f095e002b099e8afb54761e297a130b594aa3c2 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 17 Jun 2021 19:20:52 -0400 Subject: [PATCH 26/40] Update make.yml --- .github/workflows/make.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index 71f68c6..913b323 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -23,8 +23,8 @@ jobs: with: compiler: ${{ matrix.dc }} - name: make tree-query - run: (dmd && make) || true + run: (dmd && make && echo "Built successfully with DMD Reference Compiler!") || true - name: make tree-query-build - run: (ldc && make tree-query-build) || true + run: (ldc2 && make tree-query-build && echo "Built successfully with LLVM D Compiler!") || true #- name: make distcheck # run: make distcheck From ca9783f7ace2185924390197de8053fd318085b5 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 17 Jun 2021 19:23:49 -0400 Subject: [PATCH 27/40] Update make.yml --- .github/workflows/make.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index 913b323..1db18c4 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -10,7 +10,7 @@ jobs: build: strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, macOS-latest] dc: [dmd-latest, ldc-latest, dmd-2.085.0, ldc-1.17.0] exclude: - { os: macOS-latest, dc: dmd-2.085.0 } @@ -23,8 +23,8 @@ jobs: with: compiler: ${{ matrix.dc }} - name: make tree-query - run: (dmd && make && echo "Built successfully with DMD Reference Compiler!") || true + run: (which dmd && make && echo "Built successfully with DMD Reference Compiler!") || true - name: make tree-query-build - run: (ldc2 && make tree-query-build && echo "Built successfully with LLVM D Compiler!") || true + run: (which ldc2 && make tree-query-build && echo "Built successfully with LLVM D Compiler!") || true #- name: make distcheck # run: make distcheck From 9aac9418e56153717cb12e588b48fb6fbe426e37 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 17 Jun 2021 21:14:05 -0400 Subject: [PATCH 28/40] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5e23db6..505dc6f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Tree query is a tool that searches across indented lines. It is a replacement for Roam's query system. It supports everything Roam does, except for block references. +[Join us on Discord](https://discord.gg/7B9ywS5x) + ## Quickstart **Query in current directory:** From d20eeeeac4ad5abccfde3858a61ce4ccb029e0bf Mon Sep 17 00:00:00 2001 From: James Date: Thu, 17 Jun 2021 21:16:19 -0400 Subject: [PATCH 29/40] Delete make.yml --- .github/workflows/make.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .github/workflows/make.yml diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml deleted file mode 100644 index 1db18c4..0000000 --- a/.github/workflows/make.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Makefile CI - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - strategy: - matrix: - os: [ubuntu-latest, macOS-latest] - dc: [dmd-latest, ldc-latest, dmd-2.085.0, ldc-1.17.0] - exclude: - - { os: macOS-latest, dc: dmd-2.085.0 } - - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - name: Install D compiler - uses: dlang-community/setup-dlang@v1 - with: - compiler: ${{ matrix.dc }} - - name: make tree-query - run: (which dmd && make && echo "Built successfully with DMD Reference Compiler!") || true - - name: make tree-query-build - run: (which ldc2 && make tree-query-build && echo "Built successfully with LLVM D Compiler!") || true - #- name: make distcheck - # run: make distcheck From 77bf65d1318d39d16f79f5ea4e7abbe079fe6513 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 13 Jul 2021 13:50:42 -0400 Subject: [PATCH 30/40] Fix minor doc error for Unixes --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 505dc6f..3b5ba74 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,8 @@ make tree-query-build Install to make available eveywhere: ``` -chmod 700 ~/Downloads/tree-query -sudo mv ~/Downloads/tree-query /usr/local/bin +chmod 700 tree-query +sudo mv tree-query /usr/local/bin ``` ## Features From f2f75ecd2e66ad6325fb17e4855fac710b8dc2ba Mon Sep 17 00:00:00 2001 From: James Date: Fri, 23 Jul 2021 13:23:34 -0400 Subject: [PATCH 31/40] Improve Windows build instrunctions --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3b5ba74..684aa57 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ powershell.exe -Command "wget https://dlang.org/install.sh -OutFile %USERPROFILE Then: ``` +set PATH=%PATH%;C:\Program Files\7-Zip +set BASH="\Program Files\Git\usr\bin\bash.exe ~/dlang/install.sh install ldc-1.23.0,dub ``` From 0bd5f595aa3781bd35d4d7822658b37964002ac8 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 23 Jul 2021 13:59:03 -0400 Subject: [PATCH 32/40] Fix Windows build instrunctions --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 684aa57..1bb21e7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > This README is TODO. If you'd like to use this software in a project, **don't hestiate to reach out to me.** -Tree query is a tool that searches across indented lines. +`tree-query` is a tool that lets you execute queries on ordinary directories of files like text and Markdown, inspired by Roam Research's query syntax. It is a replacement for Roam's query system. It supports everything Roam does, except for block references. @@ -44,26 +44,26 @@ On FreeBSD, GNU+Linux, and macOS, open Terminal and go: curl https://dlang.org/install.sh | bash -s ``` -On Windows, download and install [Git Bash](https://gitforwindows.org/), then run: +On Windows, download and install [Git Bash](https://gitforwindows.org/) and [7-Zip to C:\Program Files](https://www.7-zip.org/), then run: ``` mkdir %USERPROFILE%\dlang -powershell.exe -Command "wget https://dlang.org/install.sh -OutFile %USERPROFILE%\dlang\install.sh" +set PATH="%PATH%;C:\Program Files\7-Zip" +set BASH="\Program Files\Git\usr\bin\bash.exe" +mkdir dlang +powershell.exe -Command "wget https://dlang.org/install.sh -OutFile dlang\install.sh" ``` Then: - ``` -set PATH=%PATH%;C:\Program Files\7-Zip -set BASH="\Program Files\Git\usr\bin\bash.exe -~/dlang/install.sh install ldc-1.23.0,dub +~/dlang/install.sh install ldc-1.23.0 ``` -Then `cd` into the directory where you cloned this directory and type: +Then `cd` into the directory where you cloned this directory (`git clone https://github.com/CrazyPython/tree-query.git && cd tree-query`) and type: ``` -make tree-query-build +~/dlang/ldc-1.23.0/bin/ldc2 --link-defaultlib-shared=false -O2 -release tree-query.d interp.d query.d parser.d ``` -Install to make available eveywhere: +(Non-Windows) Install to make available eveywhere: ``` chmod 700 tree-query sudo mv tree-query /usr/local/bin From 7ea6266e596045f3bbb09fd5418f790e1d7e340a Mon Sep 17 00:00:00 2001 From: James Date: Fri, 23 Jul 2021 14:04:16 -0400 Subject: [PATCH 33/40] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d5bcd63..3f07b60 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,10 +1,11 @@ # Release notes -## Since 0.0.1 +## 0.0.2 - Added hyperlinked documentation on usage instructions for people new to the CLI - Added missing source files, now it's possible to compile - Support for starting queries with `{query:` was enabled - Shows message when executed without a query + - Fixed build instructions for Windows and added a binary release for Windows and Mac ## 0.0.1 - Supports `{and:`, `{or:`, `{not:`, nested arbitrarily, querying using page references From 57f088bc9ca6f5884995a7532dc575eece6448f5 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 23 Jul 2021 14:08:30 -0400 Subject: [PATCH 34/40] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 3f07b60..d6b48e2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,13 +1,13 @@ # Release notes -## 0.0.2 +## 0.1.1 - Added hyperlinked documentation on usage instructions for people new to the CLI - Added missing source files, now it's possible to compile - Support for starting queries with `{query:` was enabled - Shows message when executed without a query - Fixed build instructions for Windows and added a binary release for Windows and Mac -## 0.0.1 +## 0.1.0 - Supports `{and:`, `{or:`, `{not:`, nested arbitrarily, querying using page references - Works on any kind of indentation, including tabs, spaces. - Caveat: Mixing tabs and spaces in one file may lead to undesired results, because a tab is interpreted as one space From e2bc80e72ff26372ae98d0a8a29075499b6cc81d Mon Sep 17 00:00:00 2001 From: James Date: Fri, 23 Jul 2021 14:10:03 -0400 Subject: [PATCH 35/40] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1bb21e7..bace193 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,10 @@ cat myfile | tree-query '{and: [[Page 1]] [[Page 2]]}' [*Learn to build powerful no-code applications using pipes*](https://youtu.be/tc4ROCJYbm0?t=360) ## Installation +### [Download a copy](https://github.com/CrazyPython/tree-query/releases/tag/v0.1.1) +The more convenient method. Click above for instructions. ### Build from source -Currently the only supported method. DYI style. On FreeBSD, GNU+Linux, and macOS, open Terminal and go: ``` From 30e2beafb61c7d2f0200ceec7f9e3f134b286af8 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 17 Jun 2021 18:55:36 -0400 Subject: [PATCH 36/40] Add "Your Rights" section --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bace193..e665016 100644 --- a/README.md +++ b/README.md @@ -108,4 +108,21 @@ A string in D is a reference to a region of immutable memory. It is a length and A struct is like a Java record or class. ## Known bugs - - Mixing tabs and spaces is not supported in the same file, unless an explicit spaces per indent specified + - Mixing tabs and spaces in the same file is not supported, unless an explicit spaces per indent specified + +## Your rights + +This is open-source software. + +We use copyleft to gurantee these rights: + +0. Free for commercial use and any other purpose +1. Freedom to remix to fit your needs: You (and if you can't code, by proxy a programmer you hire) have freedom to add new query keywords, completely change the query system, add support for new formats like org-mode, or anything else +2. Freedom to help friends by sharing +3. Freedom to share remixes, commercially and noncommercially + +I believe knowledge management is a deeply, and everyone should have freedom over their "digital brain." A digital brain is a deeply intimate and personal thing. This means you are the sovereign of your digital brain. + +Compatible with permissive licenses like Apache License, MIT License, and Mozilla Public License. + +(C) 2021. Affero General Public License v3.0 or any later version From b6ff559fb432108db5b37b255ee8b05fda89e1a2 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 23 Jul 2021 16:16:10 -0400 Subject: [PATCH 37/40] Add org-mode support --- parser.d | 1 + 1 file changed, 1 insertion(+) diff --git a/parser.d b/parser.d index 68a5c2b..ae1389b 100644 --- a/parser.d +++ b/parser.d @@ -14,6 +14,7 @@ int count_indents(ref int i, string input, int spaces_per_indent=4) { for (; i < input.length; ++i) { switch (input[i]) { case ' ': nspaces++; break; + case '*': nspaces++; break; case '\t': nspaces += spaces_per_indent; break; // Commented out makes it only accept "-" //case '-': return nspaces / spaces_per_indent; From 2798c61cbd19b26d26b614ce64f6b5feb9cc2d35 Mon Sep 17 00:00:00 2001 From: James Date: Sat, 24 Jul 2021 21:18:03 -0400 Subject: [PATCH 38/40] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e665016..9cbc4c4 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,8 @@ tree-query '{and: [[Page 1]] [[Page 2]]}' . | xclip ## Contributing +`tree-query` has doc comments on internals and example code demonstrating how internal APIs work. (Ctrl-F for "unittest") + Tree-query is written in [Dlang](https://dlang.org) but don't let that put you off- if you know C, C++, or Java, you'll pick it up very quickly. If you have any questions on D, feel free to go to #d on freenode or D Forums. People are very nice. From a2b791dd30798a8708889d526d205da789a05069 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 30 Jul 2021 09:20:41 -0400 Subject: [PATCH 39/40] Add file overview --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 9cbc4c4..850c1fc 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,14 @@ tree-query '{and: [[Page 1]] [[Page 2]]}' . | xclip ## Contributing +**query.d**: The logic for executing Roam queries + +**parser.d**: The Markdown parser + +**tree-query.d**: The command-line tool/wrapper. Parses the string `{and: [[Page 1]] [[Page 2]]}` into a tree of boolean expressions + +**interp.d**: Evaluates boolean expressions on behalf of query.d + `tree-query` has doc comments on internals and example code demonstrating how internal APIs work. (Ctrl-F for "unittest") Tree-query is written in [Dlang](https://dlang.org) but don't let that put you off- if you know C, C++, or Java, you'll pick it up very quickly. From a0833c524bb414378f30480af84147894ebbeeba Mon Sep 17 00:00:00 2001 From: James Date: Fri, 30 Jul 2021 09:22:46 -0400 Subject: [PATCH 40/40] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 850c1fc..4debf04 100644 --- a/README.md +++ b/README.md @@ -93,11 +93,11 @@ tree-query '{and: [[Page 1]] [[Page 2]]}' . | xclip **query.d**: The logic for executing Roam queries -**parser.d**: The Markdown parser +**parser.d**: The Markdown/org-mode parser, which detects the indentation level of each line and uses it to emit a stream of events for a handler like `query.d` to consume. -**tree-query.d**: The command-line tool/wrapper. Parses the string `{and: [[Page 1]] [[Page 2]]}` into a tree of boolean expressions +**tree-query.d**: The command-line tool/wrapper. Recursively parses the string `{and: [[Page 1]] [[Page 2]]}` into a tree of expressions -**interp.d**: Evaluates boolean expressions on behalf of query.d +**interp.d**: Recursively evaluates boolean expressions on behalf of query.d `tree-query` has doc comments on internals and example code demonstrating how internal APIs work. (Ctrl-F for "unittest")