Skip to content

Commit aff336f

Browse files
authored
Merge pull request #14 from hackmdio/feature/rename-project
2 parents 15f10ae + e3d54a9 commit aff336f

File tree

12 files changed

+113
-115
lines changed

12 files changed

+113
-115
lines changed

README.md

Lines changed: 86 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
codimd-cli - The CodiMD Command Line Tool
1+
hackmd-cli - The HackMD/CodiMD Command Line Tool
22
===
33

44
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
5-
[![Version](https://img.shields.io/npm/v/@hackmd/codimd-cli.svg)](https://npmjs.org/package/@hackmd/codimd-cli)
6-
[![Downloads/week](https://img.shields.io/npm/dw/@hackmd/codimd-cli.svg)](https://npmjs.org/package/@hackmd/codimd-cli)
7-
[![License](https://img.shields.io/npm/l/@hackmd/codimd-cli.svg)](https://github.com/hackmdio/codimd-cli/blob/master/package.json)
5+
[![Version](https://img.shields.io/npm/v/@hackmd/hackmd-cli.svg)](https://npmjs.org/package/@hackmd/hackmd-cli)
6+
[![Downloads/week](https://img.shields.io/npm/dw/@hackmd/hackmd-cli.svg)](https://npmjs.org/package/@hackmd/hackmd-cli)
7+
[![License](https://img.shields.io/npm/l/@hackmd/hackmd-cli.svg)](https://github.com/hackmdio/hackmd-cli/blob/master/package.json)
88

9-
* [codimd-cli - The CodiMD Command Line Tool](#codimd-cli---the-codimd-command-line-tool)
109
* [Usage](#usage)
1110
* [Commands](#commands)
1211
* [Configuration](#configuration)
@@ -15,67 +14,87 @@ codimd-cli - The CodiMD Command Line Tool
1514
## Usage
1615
<!-- usage -->
1716
```sh-session
18-
$ npm install -g @hackmd/codimd-cli
19-
$ codimd-cli COMMAND
17+
$ npm install -g @hackmd/hackmd-cli
18+
$ hackmd-cli COMMAND
2019
running command...
21-
$ codimd-cli (-v|--version|version)
22-
@hackmd/codimd-cli/1.0.3 linux-x64 node-v8.17.0
23-
$ codimd-cli --help [COMMAND]
20+
$ hackmd-cli (-v|--version|version)
21+
@hackmd/hackmd-cli/1.1.0 linux-x64 node-v12.16.2
22+
$ hackmd-cli --help [COMMAND]
2423
USAGE
25-
$ codimd-cli COMMAND
24+
$ hackmd-cli COMMAND
2625
...
2726
```
2827
<!-- usagestop -->
2928

3029
## Configuration
3130

32-
`codimd-cli` support both JSON file config and environment variable config.
31+
`hackmd-cli` operates on official HackMD instance(`hackmd.io`) by default. If you want to use cli with a self-hosted [CodiMD](https://github.com/hackmdio/codimd) or a [HackMD EE](https://hackmd.io/pricing) instance, you will need to configure `hackmd-cli` by either environment variable or JSON configuration.
3332

34-
The config file is located at `~/.codimd/config.json`, it should be like this:
33+
### Example 1: Use with self-hosted CodiMD instance
34+
35+
Set environment variable in your shell profile:
36+
37+
```bash
38+
export CMD_CLI_SERVER_URL=https://my.codimd-domain.dev
39+
```
40+
41+
Or in JSON file (`~/.hackmd/config.json`):
3542

3643
```json
3744
{
38-
"serverUrl": "https://my.codimd-domain.dev"
45+
"serverUrl": "https://my.codimd-domain.dev",
46+
"enterprise": false
3947
}
4048
```
4149

42-
Change the serverUrl value to your hosted CodiMD instance URL.
50+
### Example 2: Use with HackMD EE
4351

44-
You can also speicify config as environment variable. For example, append this line to your `.bashrc`:
52+
Set environment variable in your shell profile:
4553

4654
```bash
47-
export CMD_CLI_SERVER_URL=https://my.codimd-domain.dev
55+
export HMD_CLI_SERVER_URL=https://my.hackmd-ee.domain
56+
```
57+
58+
Or in JSON file (`~/.hackmd/config.json`):
59+
60+
```json
61+
{
62+
"serverUrl": "https://https://my.hackmd-ee.domain"
63+
}
4864
```
4965

66+
### Configuration Reference
67+
5068
All available configurations are listed in the table below.
5169

52-
| Config key | Environment Variable | Data Type | Example Value | Description |
53-
| ------------ |:--------------------- | ---------- | ------------------------------ | ------------------------------------ |
54-
| `serverUrl` | `CMD_CLI_SERVER_URL` | *`string`* | `https://my.codimd-domain.dev` | The CodiMD instance URL |
55-
| `cookiePath` | `CMD_CLI_COOKIE_PATH` | *`string`* | `~/.codimd/cookies.json` | File for storing login cookie states |
56-
| _n/a_ | `CMD_CLI_ID` | *`string`* | `[email protected]` | CodiMD username/email |
57-
| _n/a_ | `CMD_CLI_PASSWORD` | *`string`* | `dragon` | CodiMD password |
70+
| Config key | Environment Variable | Data Type | Example Value | Description |
71+
| ------------ | :--------------------------------------------- | ----------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
72+
| `serverUrl` | `HMD_CLI_SERVER_URL` or `CMD_CLI_SERVER_URL` | *`string`* | `https://my.codimd-domain.dev` | The instance URL |
73+
| `cookiePath` | `HMD_CLI_COOKIE_PATH` or `CMD_CLI_COOKIE_PATH` | *`string`* | `~/.hackmd/cookies.json` | File for storing login cookie states |
74+
| `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`) |
75+
| _n/a_ | `HMD_CLI_ID` or `CMD_CLI_ID` | *`string`* | `[email protected]` | Login username/email |
76+
| _n/a_ | `HMD_CLI_PASSWORD` or `CMD_CLI_PASSWORD` | *`string`* | `dragon` | Login password |
5877

5978
_Don't commit your login credentials!_
6079

6180
## Commands
6281

6382
<!-- commands -->
64-
* [`codimd-cli export [NOTEID] [OUTPUT]`](#codimd-cli-export-noteid-output)
65-
* [`codimd-cli help [COMMAND]`](#codimd-cli-help-command)
66-
* [`codimd-cli history`](#codimd-cli-history)
67-
* [`codimd-cli import [FILE]`](#codimd-cli-import-file)
68-
* [`codimd-cli login`](#codimd-cli-login)
69-
* [`codimd-cli logout`](#codimd-cli-logout)
70-
* [`codimd-cli whoami`](#codimd-cli-whoami)
83+
* [`hackmd-cli export [NOTEID] [OUTPUT]`](#hackmd-cli-export-noteid-output)
84+
* [`hackmd-cli help [COMMAND]`](#hackmd-cli-help-command)
85+
* [`hackmd-cli history`](#hackmd-cli-history)
86+
* [`hackmd-cli import [FILE]`](#hackmd-cli-import-file)
87+
* [`hackmd-cli login`](#hackmd-cli-login)
88+
* [`hackmd-cli logout`](#hackmd-cli-logout)
89+
* [`hackmd-cli whoami`](#hackmd-cli-whoami)
7190

72-
### `codimd-cli export [NOTEID] [OUTPUT]`
91+
## `hackmd-cli export [NOTEID] [OUTPUT]`
7392

74-
Export note to local file
93+
Export note to local file or stdout(if the output_file param is omitted)
7594

7695
```
7796
USAGE
78-
$ codimd-cli export [NOTEID] [OUTPUT]
97+
$ hackmd-cli export [NOTEID] [OUTPUT]
7998
8099
OPTIONS
81100
-h, --help show CLI help
@@ -84,18 +103,18 @@ OPTIONS
84103
--pdf
85104
86105
EXAMPLE
87-
$ codimd-cli export [--pdf|--md|--html] <note_id> <output_file>
106+
$ hackmd-cli export [--pdf|--md|--html] <note_id> <output_file>
88107
```
89108

90-
_See code: [src/commands/export.ts](https://github.com/hackmdio/codimd-cli/blob/v1.0.3/src/commands/export.ts)_
109+
_See code: [src/commands/export.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.0/src/commands/export.ts)_
91110

92-
### `codimd-cli help [COMMAND]`
111+
## `hackmd-cli help [COMMAND]`
93112

94-
display help for codimd-cli
113+
display help for hackmd-cli
95114

96115
```
97116
USAGE
98-
$ codimd-cli help [COMMAND]
117+
$ hackmd-cli help [COMMAND]
99118
100119
ARGUMENTS
101120
COMMAND command to show help for
@@ -106,13 +125,13 @@ OPTIONS
106125

107126
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.3/src/commands/help.ts)_
108127

109-
### `codimd-cli history`
128+
## `hackmd-cli history`
110129

111130
List history
112131

113132
```
114133
USAGE
115-
$ codimd-cli history
134+
$ hackmd-cli history
116135
117136
OPTIONS
118137
-h, --help show CLI help
@@ -126,110 +145,109 @@ OPTIONS
126145
--sort=sort property to sort by (prepend '-' for descending)
127146
128147
EXAMPLE
129-
$ codimd-cli history
148+
$ hackmd-cli history
130149
131150
ID Name
132151
A58r8ehYTlySO94oiC_MUA Note1
133152
EeNHDGocSTi70ytMMGQaaQ Note2
134153
```
135154

136-
_See code: [src/commands/history.ts](https://github.com/hackmdio/codimd-cli/blob/v1.0.3/src/commands/history.ts)_
155+
_See code: [src/commands/history.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.0/src/commands/history.ts)_
137156

138-
### `codimd-cli import [FILE]`
157+
## `hackmd-cli import [FILE]`
139158

140159
Create a note from markdown file
141160

142161
```
143162
USAGE
144-
$ codimd-cli import [FILE]
163+
$ hackmd-cli import [FILE]
145164
146165
OPTIONS
147166
-h, --help show CLI help
148167
149168
EXAMPLE
150-
$ codimd-cli import /path/to/markdown/file.md
169+
$ hackmd-cli import /path/to/markdown/file.md
151170
152171
Your note is available at https://codimd.domain/note-url
153172
```
154173

155-
_See code: [src/commands/import.ts](https://github.com/hackmdio/codimd-cli/blob/v1.0.3/src/commands/import.ts)_
174+
_See code: [src/commands/import.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.0/src/commands/import.ts)_
156175

157-
### `codimd-cli login`
176+
## `hackmd-cli login`
158177

159178
Login HackMD instance from CLI
160179

161180
```
162181
USAGE
163-
$ codimd-cli login
182+
$ hackmd-cli login
164183
165184
OPTIONS
166-
-h, --help show CLI help
167-
-u, --email=email Login email
185+
-h, --help show CLI help
186+
-u, --id=id Login email/username
187+
--ldap
168188
169189
EXAMPLE
170-
$ codimd-cli login
190+
$ hackmd-cli login
171191
172192
Enter your email: [email protected]
173193
Enter your password: *******
174194
175195
Login as HMD successfully!
176196
```
177197

178-
Alternatively, you may supply an email and password via the `CMD_CLI_ID` and `CMD_CLI_PASSWORD` environment variables, respectively.
198+
_See code: [src/commands/login.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.0/src/commands/login.ts)_
179199

180-
_See code: [src/commands/login.ts](https://github.com/hackmdio/codimd-cli/blob/v1.0.3/src/commands/login.ts)_
181-
182-
### `codimd-cli logout`
200+
## `hackmd-cli logout`
183201

184202
Logout from CLI
185203

186204
```
187205
USAGE
188-
$ codimd-cli logout
206+
$ hackmd-cli logout
189207
190208
OPTIONS
191209
-h, --help show CLI help
192210
193211
EXAMPLE
194-
$ codimd-cli logout
212+
$ hackmd-cli logout
195213
196214
You've logged out successfully
197215
```
198216

199-
_See code: [src/commands/logout.ts](https://github.com/hackmdio/codimd-cli/blob/v1.0.3/src/commands/logout.ts)_
217+
_See code: [src/commands/logout.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.0/src/commands/logout.ts)_
200218

201-
### `codimd-cli whoami`
219+
## `hackmd-cli whoami`
202220

203221
Show logged in account info
204222

205223
```
206224
USAGE
207-
$ codimd-cli whoami
225+
$ hackmd-cli whoami
208226
209227
OPTIONS
210228
-h, --help show CLI help
211229
212230
EXAMPLE
213-
$ codimd-cli whoami
231+
$ hackmd-cli whoami
214232
215-
You are logged in codimd.domain as {YOUR NAME} [user-id]
233+
You are logged in hackmd.io as {YOUR NAME} [user-id]
216234
```
217235

218-
_See code: [src/commands/whoami.ts](https://github.com/hackmdio/codimd-cli/blob/v1.0.3/src/commands/whoami.ts)_
236+
_See code: [src/commands/whoami.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.0/src/commands/whoami.ts)_
219237
<!-- commandsstop -->
220238

221-
### `codimd-cli` piping mode
239+
## `hackmd-cli` piping mode
222240

223-
You can create a note by piping text stream to codimd-cli
241+
You can create a note by piping text stream to hackmd-cli
224242

225243
```
226244
USAGE
227-
$ codimd-cli [COMMAND]
245+
$ hackmd-cli [COMMAND]
228246
229247
EXAMPLE
230-
$ cat README.md | codimd-cli
248+
$ cat README.md | hackmd-cli
231249
232-
Your note is available at https://codimd.domain/note-url
250+
Your note is available at https://hackmd.io/note-url
233251
```
234252

235253
## License

oclif.manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"1.0.3","commands":{"export":{"id":"export","description":"Export note to local file","pluginName":"@hackmd/codimd-cli","pluginType":"core","aliases":[],"examples":["$ codimd-cli export [--pdf|--md|--html] <note_id> <output_file>"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"pdf":{"name":"pdf","type":"boolean","allowNo":false},"md":{"name":"md","type":"boolean","allowNo":false},"html":{"name":"html","type":"boolean","allowNo":false}},"args":[{"name":"noteId"},{"name":"output"}]},"history":{"id":"history","description":"List history","pluginName":"@hackmd/codimd-cli","pluginType":"core","aliases":[],"examples":["$ codimd-cli history\n\nID Name\nA58r8ehYTlySO94oiC_MUA Note1\nEeNHDGocSTi70ytMMGQaaQ Note2"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"columns":{"name":"columns","type":"option","description":"only show provided columns (comma-separated)"},"sort":{"name":"sort","type":"option","description":"property to sort by (prepend '-' for descending)"},"filter":{"name":"filter","type":"option","description":"filter property by partial string matching, ex: name=foo"},"csv":{"name":"csv","type":"boolean","description":"output is csv format [alias: --output=csv]","allowNo":false},"output":{"name":"output","type":"option","description":"output in a more machine friendly format","options":["csv","json","yaml"]},"extended":{"name":"extended","type":"boolean","char":"x","description":"show extra columns","allowNo":false},"no-truncate":{"name":"no-truncate","type":"boolean","description":"do not truncate output to fit screen","allowNo":false},"no-header":{"name":"no-header","type":"boolean","description":"hide table header from output","allowNo":false}},"args":[]},"import":{"id":"import","description":"Create a note from markdown file","pluginName":"@hackmd/codimd-cli","pluginType":"core","aliases":[],"examples":["$ codimd-cli import /path/to/markdown/file.md\n\nYour note is available at https://codimd.domain/note-url\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"file"}]},"login":{"id":"login","description":"Login HackMD instance from CLI","pluginName":"@hackmd/codimd-cli","pluginType":"core","aliases":[],"examples":["$ codimd-cli login\n\nEnter your email: [email protected]\nEnter your password: *******\n\nLogin as HMD successfully!\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"email":{"name":"email","type":"option","char":"u","description":"Login email"}},"args":[]},"logout":{"id":"logout","description":"Logout from CLI","pluginName":"@hackmd/codimd-cli","pluginType":"core","aliases":[],"examples":["$ codimd-cli logout\n\nYou've logged out successfully\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"whoami":{"id":"whoami","description":"Show logged in account info","pluginName":"@hackmd/codimd-cli","pluginType":"core","aliases":[],"examples":["$ codimd-cli whoami\n\nYou are logged in codimd.domain as {YOUR NAME} [user-id]\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]}}}
1+
{"version":"1.1.0","commands":{"export":{"id":"export","description":"Export note to local file or stdout(if the output_file param is omitted)","pluginName":"@hackmd/hackmd-cli","pluginType":"core","aliases":[],"examples":["$ hackmd-cli export [--pdf|--md|--html] <note_id> <output_file>"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"pdf":{"name":"pdf","type":"boolean","allowNo":false},"md":{"name":"md","type":"boolean","allowNo":false},"html":{"name":"html","type":"boolean","allowNo":false}},"args":[{"name":"noteId"},{"name":"output"}]},"history":{"id":"history","description":"List history","pluginName":"@hackmd/hackmd-cli","pluginType":"core","aliases":[],"examples":["$ hackmd-cli history\n\nID Name\nA58r8ehYTlySO94oiC_MUA Note1\nEeNHDGocSTi70ytMMGQaaQ Note2"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"columns":{"name":"columns","type":"option","description":"only show provided columns (comma-separated)"},"sort":{"name":"sort","type":"option","description":"property to sort by (prepend '-' for descending)"},"filter":{"name":"filter","type":"option","description":"filter property by partial string matching, ex: name=foo"},"csv":{"name":"csv","type":"boolean","description":"output is csv format [alias: --output=csv]","allowNo":false},"output":{"name":"output","type":"option","description":"output in a more machine friendly format","options":["csv","json","yaml"]},"extended":{"name":"extended","type":"boolean","char":"x","description":"show extra columns","allowNo":false},"no-truncate":{"name":"no-truncate","type":"boolean","description":"do not truncate output to fit screen","allowNo":false},"no-header":{"name":"no-header","type":"boolean","description":"hide table header from output","allowNo":false}},"args":[]},"import":{"id":"import","description":"Create a note from markdown file","pluginName":"@hackmd/hackmd-cli","pluginType":"core","aliases":[],"examples":["$ hackmd-cli import /path/to/markdown/file.md\n\nYour note is available at https://hackmd.io/note-url\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"file"}]},"login":{"id":"login","description":"Login to HackMD/CodiMD server from CLI","pluginName":"@hackmd/hackmd-cli","pluginType":"core","aliases":[],"examples":["$ hackmd-cli login\n\nEnter your email: [email protected]\nEnter your password: *******\n\nLogin as HMD successfully!\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"id":{"name":"id","type":"option","char":"u","description":"Login email/username"},"ldap":{"name":"ldap","type":"boolean","allowNo":false}},"args":[]},"logout":{"id":"logout","description":"Logout from CLI","pluginName":"@hackmd/hackmd-cli","pluginType":"core","aliases":[],"examples":["$ hackmd-cli logout\n\nYou've logged out successfully\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"whoami":{"id":"whoami","description":"Show logged in account info","pluginName":"@hackmd/hackmd-cli","pluginType":"core","aliases":[],"examples":["$ hackmd-cli whoami\n\nYou are logged in hackmd.io as {YOUR NAME} [user-id]\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]}}}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "@hackmd/codimd-cli",
3-
"version": "1.0.3",
2+
"name": "@hackmd/hackmd-cli",
3+
"version": "1.1.0",
44
"author": "HackMD Team",
55
"bin": {
6-
"codimd-cli": "./bin/run"
6+
"hackmd-cli": "./bin/run"
77
},
8-
"bugs": "https://github.com/hackmdio/codimd-cli/issues",
8+
"bugs": "https://github.com/hackmdio/hackmd-cli/issues",
99
"dependencies": {
1010
"@hackmd/api": "^1.1.0",
1111
"@oclif/command": "^1.5.19",
@@ -44,20 +44,20 @@
4444
"/npm-shrinkwrap.json",
4545
"/oclif.manifest.json"
4646
],
47-
"homepage": "https://github.com/hackmdio/codimd-cli",
47+
"homepage": "https://github.com/hackmdio/hackmd-cli",
4848
"keywords": [
4949
"oclif"
5050
],
5151
"license": "MIT",
5252
"main": "lib/index.js",
5353
"oclif": {
5454
"commands": "./lib/commands",
55-
"bin": "codimd-cli",
55+
"bin": "hackmd-cli",
5656
"plugins": [
5757
"@oclif/plugin-help"
5858
]
5959
},
60-
"repository": "hackmdio/codimd-cli",
60+
"repository": "hackmdio/hackmd-cli",
6161
"scripts": {
6262
"postpack": "rm -f oclif.manifest.json",
6363
"posttest": "tslint -p test -t stylish",

0 commit comments

Comments
 (0)