mirror of
https://github.com/logseq/logseq.git
synced 2026-04-25 22:54:48 +00:00
2.4 KiB
2.4 KiB
Logseq CLI (Node)
The Logseq CLI is a Node.js program compiled from ClojureScript that connects to the db-worker-node server.
Build the CLI
clojure -M:cljs compile logseq-cli
Start db-worker-node (in another terminal)
clojure -M:cljs compile db-worker-node
node ./static/db-worker-node.js
Run the CLI
node ./static/logseq-cli.js graph list --base-url http://127.0.0.1:9101
Configuration
Optional configuration file: ~/.logseq/cli.edn
Supported keys include:
:base-url:auth-token:repo:timeout-ms:retries:output-format(use:jsonor:ednfor scripting)
CLI flags take precedence over environment variables, which take precedence over the config file.
Commands
Graph commands:
graph list- list all db graphsgraph create --graph <name>- create a new db graph and switch to itgraph switch --graph <name>- switch current graphgraph remove --graph <name>- remove a graphgraph validate --graph <name>- validate graph datagraph info [--graph <name>]- show graph metadata (defaults to current graph)
Block commands:
block add --content <text> [--page <name>] [--parent <uuid>]- add blocks; defaults to today’s journal page if no page is givenblock add --blocks <edn> [--page <name>] [--parent <uuid>]- insert blocks via EDN vectorblock add --blocks-file <path> [--page <name>] [--parent <uuid>]- insert blocks from an EDN fileblock remove --block <uuid>- remove a block and its childrenblock remove --page <name>- remove a page and its childrenblock search --text <query> [--limit <n>]- search block titles (Datalog includes?)block tree --page <name> [--format text|json|edn]- show page treeblock tree --block <uuid> [--format text|json|edn]- show block tree
Help output:
Subcommands:
block add [options] Add blocks
block remove [options] Remove block or page
block search [options] Search blocks
block tree [options] Show tree
Output formats:
- Global
--output <human|json|edn>(also accepted per subcommand)
Examples:
node ./static/logseq-cli.js graph create --graph demo --base-url http://127.0.0.1:9101
node ./static/logseq-cli.js block add --page TestPage --content "hello world"
node ./static/logseq-cli.js block search --text "hello"
node ./static/logseq-cli.js block tree --page TestPage --format json --output json