CLI

Summary

The Dendron CLI exposes Dendron's functionality via the command line.

Common Options

End anchor dev not found

Engine Commands

doctor

Summary

Fix your notes using doctor

Usage

NOTE: the fixFrontmatter option is only available via the plugin at this time

doctor helps you fix your notes

Options:
  --version         Show version number                                [boolean]
  --help            Show help                                          [boolean]
  --wsRoot          location of workspace
  --vault           name of vault
  --quiet           don't print output to stdout
  --enginePort      If set, connect to to running engine. If not set, create new
                    instance of Dendron Engine
  --attach          Use existing engine instead of spawning a new one
  --useLocalEngine  If set, use in memory engine instead of connecting to a
                    server                                             [boolean]
  --action          what action the doctor should take
      [string] [choices: "fixFrontmatter", "h1ToTitle", "h1ToH2", "removeStubs",
              "createMissingLinkedNotes", "regenerateNoteId", "findBrokenLinks",
           "fixRemoteVaults", "fixAirtableMetadata", "addMissingDefaultConfigs",
                    "removeDeprecatedConfigs", "fixSelfContainedVaultsInConfig"]
  --query           run doctor over a query                             [string]
  --limit           limit num changes                                   [number]
  --dryRun          dry run                                            [boolean]
  --podId           podId used to export note(s) to Airtable            [string]

Options

--action

What action should the doctor take to mend the notes.

Values:

  • h1ToTitle:

    • Remove initial h1 header and use it to replace contents of title field in frontmatter

  • h1ToH2:

    • Convert all initial h1 header to h2 header

  • removeStubs:

    • Remove all stub docs

  • createMissingLinkedNotes:

    • Create notes that do not exist yet but has a wikilink to it.
    • A preview pane will appear with the notes that will be created before proceeding.
    • In a multi-vault workspace, wikilinks that do not specify a vault prefix will be omitted from the candidates.
      • In a workspace that has 2 vaults named foo and bar, the wikilink [[missing-note]] will not be a candidate for missing note creation with this command.
      • However, [[dendron://foo/missing-note]] and / or [[dendron://bar/missing-note]] will be recognized as a missing note and will be listed as candidates.

  • regenerateNoteId:

    Regenerates the IDs of your notes.

    • Command: Dendron: Doctor
    • Option: regenerateNoteId

    If you publish your notes, this will break the published links to your notes.

    To change the scope of using this command (single note vs. workspace), remember to follow the notice in Dendron Doctor Details.

  • findBrokenLinks:

    Similar to createMissingLinkedNotes: find all broken links (that have a vault prefix). This does note create new notes.

    • Command: Dendron: Doctor
    • Option: findBrokenLinks

    This simply lists all broken links in the scope.

  • fixRemoteVaults:

    If you have a remote vault that is not correctly marked as such in the configuration, this action will fix your config file for you.

    • Command: Dendron: Doctor
    • Option: fixRemoteVaults

  • fixAirtableMetadata:

    Update airtable export pod metadata to latest version. Before running this command, Navigate to the domain of the hiearchy (eg. tasks) that is currently exported When run, the doctor will ask for the following:

    • hierarchy to export (same hierarchy you are currently on)
    • pod id that this hierarchy is exported to (select the relevant pod config)

    After doctor has run, it will convert all scalar airtable destinations to the new value

  • addMissingDefaultConfigs:

    • Detects if there are any missing configurations that are required or has a default value in dendron.yml.

    • When a missing configuration exists, a backup of dendron.yml is created and the missing keys are added with their corresponding default values.

    • Command: Dendron: Doctor

    • Option: addMissingDefaultConfigs

  • removeDeprecatedConfigs:

    • Detects if there are any deprecated configurations that are still in dendron.yml.

    • When a deprecated configuration key exists, a backup of dendron.yml is created and the deprecated keys are removed.

    • Command: Dendron: Doctor

    • Option: removeDeprecatedConfigs

  • fixSelfContainedVaultsInConfig: Fixes issues in the dendron.yml when using/moving to a self-contained vault

Examples

  • convert all h1 tags to frontmatter title values for the readings hierarchy
dendron doctor --wsRoot . --action h1ToTitle --limit 10 --query "readings.*" 
  • see log
LOG_LEVEL=info LOG_DST=stdout dendron doctor --wsRoot . --action h1ToTitle --limit 10 

launchEngineServer

Summary

Launch an instance of dendron engine

Usage

Launch the (In Progress)Dendron server. Useful for development purposes or to launch the server in a specified port

The CLI will also write out .dendron.* metadata files in the workspace root just the same as the Dendron plugin.

launch instance of dendron engine

Options:
  --version      Show version number                                   [boolean]
  --help         Show help                                             [boolean]
  --wsRoot       location of workspace
  --vault        name of vault
  --quiet        don't print output to stdout
  --port         port to launch server                                  [number]
  --init         initialize server                                     [boolean]
  --noWritePort  don't write the port to a file                        [boolean]
  --fast         launch engine without indexing                        [boolean]

Examples

dendron launchEngineServer --wsRoot ~/Dendron/ --port 3005

Publishing Commands

Summary

Commands for publishing your notes

Usage

dendron publish <cmd>

commands for publishing notes

Positionals:
  cmd  a command to run
                 [string] [required] [choices: "init", "build", "dev", "export"]

Options:
  --version    Show version number                                     [boolean]
  --help       Show help                                               [boolean]
  --wsRoot     location of workspace
  --vault      name of vault
  --quiet      don't print output to stdout
  --dest       override where nextjs-template is located                [string]
  --attach     use existing dendron engine instead of spawning a new one
                                                                       [boolean]
  --noBuild    skip building notes                    [boolean] [default: false]
  --overrides  override existing siteConfig properties                  [string]
  --target     export to specific destination                           [string]
  --sitemap    generates a sitemap
  --yes        automatically say yes to all prompts

See Publish for more information about publishing your notes.

Commands

init

Initialize Next.js template and all dependencies

build

Prepare notes for publication. Runs Next.js pod in the background.

dev

Builds notes and starts a local dev server. Behind the scenes, runs dendron publish build && npx next dev

export

Export notes as static HTML

Examples

  • build and preview the site locally
dendron publish dev
  • build your site to prepare for publication

    Run the following command to prepare your notes for publishing.

    npx dendron publish build
    

  • override a default option while building

dendron publish build --overrides="siteUrl=foo.com"

Pod Commands

Summary

CLI commands for interacting with pods

NOTE: you can find pod ids in the pods page

Usage

Commands

Export Pod

Summary

Use pods to export your notes to another pod type

Usage

Actions

The below provide an overview of the purpose of action the doctor command can run.

use a pod to export notes

Options:
  --version         Show version number                                [boolean]
  --help            Show help                                          [boolean]
  --wsRoot          location of workspace
  --vault           name of vault
  --quiet           don't print output to stdout
  --enginePort      If set, connect to to running engine. If not set, create new
                    instance of Dendron Engine
  --attach          Use existing engine instead of spawning a new one
  --useLocalEngine  If set, use in memory engine instead of connecting to a
                    server                                             [boolean]
  --podId           id of pod to use
  --showConfig      show pod configuration
  --genConfig       show pod configuration
  --podPkg          if specifying a custom pod, name of pkg
  --config          pass in config instead of reading from file. format is comma
                    delimited {key}={value} pairs
  --podSource       podSource[choices: "custom", "builtin"] [default: "builtin"]

Examples

  • export note to a JSONpod
dendron exportPod --podId dendron.json --wsRoot . 

Import Pod

Summary

Use pods to import your notes from another pod type

Usage

use a pod to import notes

Options:
  --version         Show version number                                [boolean]
  --help            Show help                                          [boolean]
  --wsRoot          location of workspace
  --vault           name of vault
  --quiet           don't print output to stdout
  --enginePort      If set, connect to to running engine. If not set, create new
                    instance of Dendron Engine
  --attach          Use existing engine instead of spawning a new one
  --useLocalEngine  If set, use in memory engine instead of connecting to a
                    server                                             [boolean]
  --podId           id of pod to use
  --showConfig      show pod configuration
  --genConfig       show pod configuration
  --podPkg          if specifying a custom pod, name of pkg
  --config          pass in config instead of reading from file. format is comma
                    delimited {key}={value} pairs
  --podSource       podSource[choices: "custom", "builtin"] [default: "builtin"]

Examples

  • Import notes from FilePod
dendron importPod --podId dendron.markdown --wsRoot . 

Publish Pod

Summary

Publish a note to a pod

Usage

publish a note

Options:
  --version         Show version number                                [boolean]
  --help            Show help                                          [boolean]
  --wsRoot          location of workspace
  --vault           name of vault
  --quiet           don't print output to stdout
  --enginePort      If set, connect to to running engine. If not set, create new
                    instance of Dendron Engine
  --attach          Use existing engine instead of spawning a new one
  --useLocalEngine  If set, use in memory engine instead of connecting to a
                    server                                             [boolean]
  --podId           id of pod to use
  --showConfig      show pod configuration
  --genConfig       show pod configuration
  --podPkg          if specifying a custom pod, name of pkg
  --config          pass in config instead of reading from file. format is comma
                    delimited {key}={value} pairs
  --podSource       podSource[choices: "custom", "builtin"] [default: "builtin"]

Options

--query

Name of note to publish

Examples

  • Publish dendron.md note as Markdown
dendron publishPod --wsRoot . --podId dendron.markdown --query dendron

Common Options

--configPath

Path to a custom yml configuration for the pod

Vault Commands

Summary

Manage your vaults via the CLI

Usage

vault related commands

Positionals:
  cmd  a command to run       [string] [required] [choices: "create", "convert"]

Options:
  --version         Show version number                                [boolean]
  --help            Show help                                          [boolean]
  --wsRoot          location of workspace
  --vault           name of vault
  --quiet           don't print output to stdout
  --enginePort      If set, connect to to running engine. If not set, create new
                    instance of Dendron Engine
  --attach          Use existing engine instead of spawning a new one
  --useLocalEngine  If set, use in memory engine instead of connecting to a
                    server                                             [boolean]
  --vaultPath       path to vault                            [string] [required]
  --noAddToConfig   if set, don't add vault to dendron.yml             [boolean]
  --remoteUrl       If converting to a remote vault, URL of the remote to use.
                    Like https://github.com/dendronhq/dendron-site.git or
                    git@github.com:dendronhq/dendron-site.git           [string]
  --type            If converting a vault, what type of vault to convert it to.
                                           [string] [choices: "remote", "local"]

Commands

create

Create a new vault within the workspace

convert

Convert a vault from remote to local, or local to remote

Examples

  • Create a new vault
dendron vault create --vaultPath kevin-test --wsRoot .
  • Convert a vault to remote from local
dendron vault convert --vaultPath kevin-test --wsRoot . --type remote --remoteURL https://github.com/dendronhq/dendron-site.git

Workspace Commands

Summary

Manage your workspace via the CLI

Usage

dendron workspace <cmd>

workspace related commands

Positionals:
  cmd  a command to run
           [string] [required] [choices: "pull", "push", "addAndCommit", "sync",
                                                  "removeCache", "init", "info"]

Options:
  --version         Show version number                                [boolean]
  --help            Show help                                          [boolean]
  --wsRoot          location of workspace
  --vault           name of vault
  --quiet           don't print output to stdout
  --enginePort      If set, connect to to running engine. If not set, create new
                    instance of Dendron Engine
  --attach          Use existing engine instead of spawning a new one
  --useLocalEngine  If set, use in memory engine instead of connecting to a
                    server                                             [boolean]

Commands

init

Initialize a Workspace.

pull

Run git pull --rebase on all vaults inside workspace

push

Run git push on all vaults inside workspace

addAndCommit

Run git add . && git commit on all vaults inside the workspace

sync

Run addAndCommit, pull, and push on all vaults inside the workspace. This follows the same configuration as the Workspace: Sync command in the extension, see Workspace Sync for details.

Note Commands

Usage

note related commands

Positionals:
  cmd  a command to run[string] [required] [choices: "get", "find", "lookup", "delete", "move"]

Options:
  --version         Show version number                                [boolean]
  --help            Show help                                          [boolean]
  --wsRoot          location of workspace
  --vault           name of vault
  --quiet           don't print output to stdout
  --enginePort      If set, connect to to running engine. If not set, create new
                    instance of Dendron Engine
  --attach          Use existing engine instead of spawning a new one
  --useLocalEngine  If set, use in memory engine instead of connecting to a
                    server                                             [boolean]
  --query           the query to run                                    [string]
  --output          format to output in
            [string] [choices: "json", "md_gfm", "md_dendron"] [default: "json"]
  --fname           name of file to find/write                          [string]
  --body            body of file to write                               [string]
  --destFname       name to change to (for move)                        [string]
  --destVaultName   vault to move to (for move)                         [string]

Commands

get

Get a note by id.

find

Find notes by note properties

lookup

Find or create a note if one does not exist, outputting in a specified format.

delete

Delete a note from a vault.

write

Creates a new note if fname/vault doesn't exist or updates body of existing note

move

Move a note to another vault, or rename a note within a workspace.

Options

--query

Note to query for. Same syntax as Lookup

--output

Controls how note is formatted

Values:

  • json: JSON output
  • md_dendron: dendron markdown
  • md_gfm: github flavored markdown

Examples

  • Creating a note (or updating an existing note)
# creates hello if it does not exist. updates hello if it does exist.
dendron note write --fname "mytest" --vault "vaultName" --body "this is a body"
  • Getting a note
dendron note get --query "noteId"
  • Finding notes
dendron note find --fname "foo"
  • Querying a note
# retrieves hello.md if it does exist
dendron note lookup --query "hello" 
  • Querying a note with GitHub Flavored Markdown output
# retrieves hello.md if it does exist
dendron note lookup --query "hello" --output md_gfm
  • Deleting a note
dendron note delete --fname "foo"
  • Deleting a note within a multi-vault workspace
dendron note delete --vault vault2 --fname "foo"
  • Moving a note
# renames the note "foo" to "bar" within a single-vault workspace
#   if there is no note in the vault already named "bar"
dendron note move --fname "foo" --destFname "bar"
  • Moving a note in a multi-vault workspace
# moves the note "foo" to vault2 and changes its name to "bar"
#    if there is no note in vault2 already named "bar"
dendron note move --vault vault --fname "foo" --destFname "bar" --destVaultName vault2

Dev Commands

Start anchor dev not found


Backlinks