Skip to content

Commit 4938246

Browse files
fix(cli): hint not showing up for sync subcommands
e.g. `sync status` and e2ee-password-not-found error
1 parent 90891fd commit 4938246

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/main/logseq/cli/format.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
(defn- format-error
204204
[error command]
205205
(let [{:keys [code message candidates context]} error
206-
hint (or (error-hint error command) (:hint context))
206+
hint (or (error-hint error command) (:hint error) (:hint context))
207207
message* (style/bold-keywords message ["option" "command" "argument"])
208208
candidates* (format-candidates candidates)]
209209
(if (= :graph-validation-failed code)

src/test/logseq/cli/format_test.cljs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,15 @@
8383
:context {:code :missing-auth
8484
:hint "Run `logseq login` first."}}}
8585
{:output-format nil})]
86-
(is (= "Error (missing-auth): missing auth\nHint: Run `logseq login` first." result)))))
86+
(is (= "Error (missing-auth): missing auth\nHint: Run `logseq login` first." result))))
87+
88+
(testing "human error with hint directly on error map"
89+
(let [result (format/format-result {:status :error
90+
:error {:code :e2ee-password-not-found
91+
:message "e2ee-password not found"
92+
:hint "Provide --e2ee-password to verify and persist it."}}
93+
{:output-format nil})]
94+
(is (= "Error (e2ee-password-not-found): e2ee-password not found\nHint: Provide --e2ee-password to verify and persist it." result)))))
8795

8896
(deftest test-format-graph-validation
8997
(testing "graph validation success prints validated"

0 commit comments

Comments
 (0)