File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed
Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change 1515 (= :graph (:export-type options))
1616 (assoc :graph-options (dissoc options :file :export-type :graph ))))
1717 file (or (:file options) (str graph " _" (quot (common-util/time-ms ) 1000 ) " .edn" ))]
18- (println " Exported" (count (:properties export-map)) " properties,"
19- (count (:properties export-map)) " classes and"
20- (count (:pages-and-blocks export-map)) " pages to" file)
18+ (println (str " Exported " (cli-util/summarize-build-edn export-map) " to " file))
2119 (fs/writeFileSync file
2220 (with-out-str (pprint/pprint export-map))))
2321 (cli-util/error " Graph" (pr-str graph) " does not exist" )))
Original file line number Diff line number Diff line change 1010 [promesa.core :as p]))
1111
1212(defn- print-success [import-map]
13- (println " Imported" (count (:properties import-map)) " properties,"
14- (count (:classes import-map)) " classes and"
15- (count (:pages-and-blocks import-map)) " pages!" ))
13+ (println (str " Imported " (cli-util/summarize-build-edn import-map) " !" )))
1614
1715(defn- api-import [api-server-token import-map]
1816 (-> (p/let [resp (cli-util/api-fetch api-server-token " logseq.cli.import_edn" [(sqlite-util/transit-write import-map)])]
Original file line number Diff line number Diff line change 11(ns ^:node-only logseq.cli.util
22 " CLI only util fns"
3- (:require [" path " :as node-path ]
4- [" fs " :as fs ]
3+ (:require [" fs " :as fs ]
4+ [" path " :as node-path ]
55 [clojure.string :as string]
66 [logseq.cli.common.graph :as cli-common-graph]
77 [logseq.db.common.sqlite :as common-sqlite]
6767 " Prints error and then exits"
6868 [& strings]
6969 (apply println " Error:" strings)
70- (js/process.exit 1 ))
70+ (js/process.exit 1 ))
71+
72+ (defn summarize-build-edn
73+ " Given a sqlite.build EDN map, returns a string summarizing what is transacted"
74+ [edn-map]
75+ (let [pluralize (fn pluralize [word num]
76+ (if (= 1 num)
77+ word
78+ (get {" property" " properties"
79+ " class" " classes" } word (str word " s" ))))]
80+ (str (count (:properties edn-map)) " " (pluralize " property" (count (:properties edn-map))) " , "
81+ (count (:classes edn-map)) " " (pluralize " class" (count (:classes edn-map))) " and "
82+ (count (:pages-and-blocks edn-map)) " " (pluralize " page" (count (:pages-and-blocks edn-map))))))
You can’t perform that action at this time.
0 commit comments