8000 GitHub - hackmdio/hackmd-cli at v1.2.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

hackmdio/hackmd-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hackmd-cli - The HackMD/CodiMD Command Line Tool

oclif Version Downloads/week License

Usage

$ npm install -g @hackmd/hackmd-cli
$ hackmd-cli COMMAND
running command...
$ hackmd-cli (-v|--version|version)
@hackmd/hackmd-cli/1.2.0 darwin-x64 node-v12.21.0
$ hackmd-cli --help [COMMAND]
USAGE
  $ hackmd-cli COMMAND
...

Configuration

hackmd-cli operates on official HackMD instance(hackmd.io) by default. If you want to use cli with a self-hosted CodiMD or a HackMD EE instance, you will need to configure hackmd-cli by either environment variable or JSON configuration.

Example 1: Use with self-hosted CodiMD instance

Set environment variable in your shell profile:

export CMD_CLI_SERVER_URL=https://my.codimd-domain.dev

Or in JSON file (~/.hackmd/config.json):

{
  "serverUrl": "https://my.codimd-domain.dev",
  "enterprise": false
}

Example 2: Use with HackMD EE

Set environment variable in your shell profile:

export HMD_CLI_SERVER_URL=https://my.hackmd-ee.domain

Or in JSON file (~/.hackmd/config.json):

{
  "serverUrl": "https://my.hackmd-ee.domain"
}

Configuration Reference

All available configurations are listed in the table below.

Config key Environment Variable Data Type Example Value Description
serverUrl HMD_CLI_SERVER_URL or CMD_CLI_SERVER_URL string https://my.codimd-domain.dev The instance URL
cookiePath HMD_CLI_COOKIE_PATH or CMD_CLI_COOKIE_PATH string ~/.hackmd/cookies.json File for storing login cookie states
enterprise n/a boolean true Set whether the instance is enterise version expclitly. This config can only be set in JSON based config. When providing server url with environment variable, enterprise will be automatically set by checking the env prefix(HMD or CMD)
n/a HMD_CLI_ID or CMD_CLI_ID string me@codimd-domain.dev Login username/email
n/a HMD_CLI_PASSWORD or CMD_CLI_PASSWORD string dragon Login password

Don't commit your login credentials!

Commands

hackmd-cli export [NOTEID] [OUTPUT]

Export note to local file or stdout(if the output_file param is omitted)

USAGE
  $ hackmd-cli export [NOTEID] [OUTPUT]

OPTIONS
  -h, --help  show CLI help
  --html
  --md
  --pdf

EXAMPLE
  $ hackmd-cli export [--pdf|--md|--html] <note_id> <output_file>

See code: src/commands/export.ts

hackmd-cli help [COMMAND]

display help for hackmd-cli

USAGE
  $ hackmd-cli help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

hackmd-cli history

List history

USAGE
  $ hackmd-cli history

OPTIONS
  -h, --help              show CLI help
  -x, --extended          show extra columns
  --columns=columns       only show provided columns (comma-separated)
  --csv                   output is csv format [alias: --output=csv]
  --filter=filter         filter property by partial string matching, ex: name=foo
  --no-header             hide table header from output
  --no-truncate           do not truncate output to fit screen
  --output=csv|json|yaml  output in a more machine friendly format
  --sort=sort             property to sort by (prepend '-' for descending)

EXAMPLE
  $ hackmd-cli history

  ID                     Name
  A58r8ehYTlySO94oiC_MUA Note1
  EeNHDGocSTi70ytMMGQaaQ Note2

See code: src/commands/history.ts

< AA01 h2 tabindex="-1" class="heading-element" dir="auto">hackmd-cli import [FILE]

Create a note from markdown file

USAGE
  $ hackmd-cli import [FILE]

OPTIONS
  -h, --help       show CLI help
  -t, --team=team  team to use

EXAMPLE
  $ hackmd-cli import /path/to/markdown/file.md --team=xxx

  Your note is available at https://hackmd.io/note-url

See code: src/commands/import.ts

hackmd-cli list

List owned notes or team notes (HackMD-only feature)

USAGE
  $ hackmd-cli list

OPTIONS
  -h, --help              show CLI help
  -t, --team=team         team name
  -x, --extended          show extra columns
  --columns=columns       only show provided columns (comma-separated)
  --csv                   output is csv format [alias: --output=csv]
  --filter=filter         filter property by partial string matching, ex: name=foo
  --no-header             hide table header from output
  --no-truncate           do not truncate output to fit screen
  --output=csv|json|yaml  output in a more machine friendly format
  --sort=sort             property to sort by (prepend '-' for descending)

EXAMPLE
  $ hackmd-cli list

  ID                     Name
  A58r8ehYTlySO94oiC_MUA Note1
  EeNHDGocSTi70ytMMGQaaQ Note2

See code: src/commands/list.ts

hackmd-cli login

Login to HackMD/CodiMD server from CLI

USAGE
  $ hackmd-cli login

OPTIONS
  -h, --help   show CLI help
  -u, --id=id  Login email/username
  --ldap

EXAMPLE
  $ hackmd-cli login

  Enter your email: hello@hackmd.io
  Enter your password: *******

  Login as HMD successfully!

See code: src/commands/login.ts

hackmd-cli logout

Logout from CLI

USAGE
  $ hackmd-cli logout

OPTIONS
  -h, --help  show CLI help

EXAMPLE
  $ hackmd-cli logout

  You've logged out successfully

See code: src/commands/logout.ts

hackmd-cli teams

HackMD Teams Command

USAGE
  $ hackmd-cli teams

OPTIONS
  -h, --help              show CLI help
  -x, --extended          show extra columns
  --columns=columns       only show provided columns (comma-separated)
  --csv                   output is csv format [alias: --output=csv]
  --filter=filter         filter property by partial string matching, ex: name=foo
  --no-header             hide table header from output
  --no-truncate           do not truncate output to fit screen
  --output=csv|json|yaml  output in a more machine friendly format
  --sort=sort             property to sort by (prepend '-' for descending)

EXAMPLE
  $ hackmd-cli teams

  Path            Name
  team1           Team 1
  my-awesome-team My Awesome Team

See code: src/commands/teams.ts

hackmd-cli whoami

Show logged in account info

USAGE
  $ hackmd-cli whoami

OPTIONS
  -h, --help  show CLI help

EXAMPLE
  $ hackmd-cli whoami

  You are logged in hackmd.io as {YOUR NAME} [user-id]

See code: src/commands/whoami.ts

hackmd-cli piping mode

You can create a note by piping text stream to hackmd-cli

USAGE
  $ hackmd-cli [COMMAND]

EXAMPLE
  $ cat README.md | hackmd-cli

  Your note is available at https://hackmd.io/note-url

License

MIT

0