From 18b5ecd356ed1b4f3160ac79413f3dbd6076792e Mon Sep 17 00:00:00 2001 From: Gabriel Horner Date: Wed, 15 Apr 2026 09:00:36 -0400 Subject: [PATCH] fix(cli): some list commands showing unused options asset, task and node were showing 2 options that don't apply to them --- src/main/logseq/cli/command/list.cljs | 25 +++++++++++++++---------- src/test/logseq/cli/commands_test.cljs | 4 ---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/logseq/cli/command/list.cljs b/src/main/logseq/cli/command/list.cljs index c37243ab69..e47e66bb5a 100644 --- a/src/main/logseq/cli/command/list.cljs +++ b/src/main/logseq/cli/command/list.cljs @@ -7,15 +7,12 @@ [logseq.cli.server :as cli-server] [logseq.cli.transport :as transport] [logseq.common.util :as common-util] - [promesa.core :as p] - [logseq.db.frontend.property :as db-property])) + [logseq.db.frontend.property :as db-property] + [promesa.core :as p])) +;; Common for all subcommands (def ^:private list-common-spec - {:expand {:desc "Include expanded metadata" - :alias :e - :coerce :boolean} - :include-built-in {:coerce :boolean} - :fields {:desc "Select output fields (comma separated)" + {:fields {:desc "Select output fields (comma separated)" :alias :f} :limit {:desc "Limit results" :coerce :long} @@ -26,6 +23,14 @@ :order {:desc "Sort order. Default: asc" :validate #{"asc" "desc"}}}) +;; Common for all page-related subcommands +(def ^:private list-common-page-spec + {:expand {:desc "Include expanded metadata" + :alias :e + :coerce :boolean} + :include-built-in {:desc "Include built-in nodes" + :coerce :boolean}}) + (def ^:private default-sort-field "updated-at") (def ^:private available-task-priority-values @@ -66,9 +71,9 @@ (merge-with merge list-common-spec + list-common-page-spec {:sort {:validate (set (keys list-page-field-map))} :fields {:multiple-values (keys list-page-field-map)} - :include-built-in {:desc "Include built-in pages"} :include-journal {:desc "Include journal pages" :coerce :boolean} :journal-only {:desc "Only journal pages" @@ -94,9 +99,9 @@ (merge-with merge list-common-spec + list-common-page-spec {:sort {:validate (set (keys list-tag-field-map))} :fields {:multiple-values (keys list-tag-field-map)} - :include-built-in {:desc "Include built-in tags"} :with-properties {:desc "Include tag properties" :coerce :boolean} :with-extends {:desc "Include tag extends" @@ -119,9 +124,9 @@ (merge-with merge list-common-spec + list-common-page-spec {:sort {:validate (set (keys list-property-field-map))} :fields {:multiple-values (keys list-property-field-map)} - :include-built-in {:desc "Include built-in properties"} :with-classes {:desc "Include property classes" :coerce :boolean} :with-type {:desc "Include property type" diff --git a/src/test/logseq/cli/commands_test.cljs b/src/test/logseq/cli/commands_test.cljs index 152f3f8038..a81fb8d67a 100644 --- a/src/test/logseq/cli/commands_test.cljs +++ b/src/test/logseq/cli/commands_test.cljs @@ -1149,7 +1149,6 @@ (let [result (commands/parse-args ["list" "node" "--tags" "project,work" "--properties" "status,priority" - "--expand" "--fields" "id,title,type,updated-at" "--limit" "10" "--offset" "2" @@ -1159,7 +1158,6 @@ (is (= :list-node (:command result))) (is (= "project,work" (get-in result [:options :tags]))) (is (= "status,priority" (get-in result [:options :properties]))) - (is (true? (get-in result [:options :expand]))) (is (= "id,title,type,updated-at" (get-in result [:options :fields]))) (is (= 10 (get-in result [:options :limit]))) (is (= 2 (get-in result [:options :offset]))) @@ -1168,7 +1166,6 @@ (testing "list asset parses with common list options" (let [result (commands/parse-args ["list" "asset" - "--expand" "--fields" "id,title,asset-type,size,updated-at" "--limit" "5" "--offset" "1" @@ -1176,7 +1173,6 @@ "--order" "desc"])] (is (true? (:ok? result))) (is (= :list-asset (:command result))) - (is (true? (get-in result [:options :expand]))) (is (= "id,title,asset-type,size,updated-at" (get-in result [:options :fields]))) (is (= 5 (get-in result [:options :limit]))) (is (= 1 (get-in result [:options :offset])))