mirror of
https://github.com/logseq/logseq.git
synced 2026-02-01 22:47:36 +00:00
011-logseq-cli-search-optimization.md (2)
This commit is contained in:
@@ -97,7 +97,7 @@ Options grouping:
|
||||
Output formats:
|
||||
- Global `--output <human|json|edn>` (also accepted per subcommand)
|
||||
- For `graph export`, `--output` refers to the destination file path. Output formatting is controlled via `:output-format` in config or `LOGSEQ_CLI_OUTPUT`.
|
||||
- Human output is plain text. List/search commands render tables with a final `Count: N` line. For list and search subcommands, the ID column uses `:db/id` (not UUID). If `:db/ident` exists, an `IDENT` column is included. Search table columns are `ID` and `TITLE`. Times such as list `UPDATED-AT`/`CREATED-AT` and `graph info` `Created at` are shown in human-friendly relative form. Errors include error codes and may include a `Hint:` line. Use `--output json|edn` for structured output.
|
||||
- Human output is plain text. List/search commands render tables with a final `Count: N` line. For list and search subcommands, the ID column uses `:db/id` (not UUID). If `:db/ident` exists, an `IDENT` column is included. Search table columns are `ID` and `TITLE`. Block titles can include multiple lines; multi-line rows align additional lines under the `TITLE` column. Times such as list `UPDATED-AT`/`CREATED-AT` and `graph info` `Created at` are shown in human-friendly relative form. Errors include error codes and may include a `Hint:` line. Use `--output json|edn` for structured output.
|
||||
- Show and search outputs resolve block reference UUIDs inside text, replacing `[[<uuid>]]` with the referenced block content. Nested references are resolved recursively up to 10 levels to avoid excessive expansion. For example: `[[<uuid1>]]` → `[[some text [[<uuid2>]]]]` and then `<uuid2>` is also replaced.
|
||||
- `show` human output prints the `:db/id` as the first column followed by a tree:
|
||||
|
||||
|
||||
@@ -40,22 +40,35 @@
|
||||
|
||||
(defn- render-table
|
||||
[headers rows]
|
||||
(let [normalized-rows (mapv (fn [row]
|
||||
(mapv normalize-cell row))
|
||||
(let [split-lines (fn [value]
|
||||
(string/split (normalize-cell value) #"\n" -1))
|
||||
normalized-rows (mapv (fn [row]
|
||||
(mapv split-lines row))
|
||||
rows)
|
||||
trim-right (fn [value]
|
||||
(string/replace value #"\s+$" ""))
|
||||
widths (mapv (fn [idx header]
|
||||
(apply max (count header)
|
||||
(map #(count (nth % idx)) normalized-rows)))
|
||||
(reduce max
|
||||
(count header)
|
||||
(mapcat #(map count (nth % idx)) normalized-rows)))
|
||||
(range (count headers))
|
||||
headers)
|
||||
render-row (fn [row]
|
||||
(->> (map pad-right row widths)
|
||||
(string/join " ")
|
||||
(trim-right)))
|
||||
render-multiline-row (fn [row]
|
||||
(let [line-count (reduce max 1 (map count row))]
|
||||
(mapv (fn [line-idx]
|
||||
(->> (map-indexed (fn [col-idx lines]
|
||||
(pad-right (get lines line-idx "")
|
||||
(nth widths col-idx)))
|
||||
row)
|
||||
(string/join " ")
|
||||
(trim-right)))
|
||||
(range line-count))))
|
||||
lines (cons (render-row headers)
|
||||
(map render-row normalized-rows))]
|
||||
(mapcat render-multiline-row normalized-rows))]
|
||||
(string/join "\n" lines)))
|
||||
|
||||
(defn- format-counted-table
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
:created-at 1}
|
||||
{:type "block"
|
||||
:db/id 102
|
||||
:content "Note"
|
||||
:content "Note line 1\nNote line 2"
|
||||
:uuid "u2"
|
||||
:updated-at 4
|
||||
:created-at 2}
|
||||
@@ -186,7 +186,8 @@
|
||||
{:output-format nil})]
|
||||
(is (= (str "ID TITLE\n"
|
||||
"101 Alpha\n"
|
||||
"102 Note\n"
|
||||
"102 Note line 1\n"
|
||||
" Note line 2\n"
|
||||
"103 Taggy\n"
|
||||
"104 Prop\n"
|
||||
"Count: 4")
|
||||
|
||||
Reference in New Issue
Block a user