mirror of
https://github.com/logseq/logseq.git
synced 2026-05-28 14:39:48 +00:00
fix(cli): some list commands showing unused options
asset, task and node were showing 2 options that don't apply to them
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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])))
|
||||
|
||||
Reference in New Issue
Block a user