Skip to content

Commit b85c547

Browse files
authored
Merge pull request #22 from hackmdio/develop
Release 1.1.1
2 parents aff336f + 571787f commit b85c547

File tree

7 files changed

+114
-29
lines changed

7 files changed

+114
-29
lines changed

README.md

+43-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $ npm install -g @hackmd/hackmd-cli
1818
$ hackmd-cli COMMAND
1919
running command...
2020
$ hackmd-cli (-v|--version|version)
21-
@hackmd/hackmd-cli/1.1.0 linux-x64 node-v12.16.2
21+
@hackmd/hackmd-cli/1.1.1 darwin-x64 node-v12.16.2
2222
$ hackmd-cli --help [COMMAND]
2323
USAGE
2424
$ hackmd-cli COMMAND
@@ -86,6 +86,7 @@ _Don't commit your login credentials!_
8686
* [`hackmd-cli import [FILE]`](#hackmd-cli-import-file)
8787
* [`hackmd-cli login`](#hackmd-cli-login)
8888
* [`hackmd-cli logout`](#hackmd-cli-logout)
89+
* [`hackmd-cli teams`](#hackmd-cli-teams)
8990
* [`hackmd-cli whoami`](#hackmd-cli-whoami)
9091

9192
## `hackmd-cli export [NOTEID] [OUTPUT]`
@@ -106,7 +107,7 @@ EXAMPLE
106107
$ hackmd-cli export [--pdf|--md|--html] <note_id> <output_file>
107108
```
108109

109-
_See code: [src/commands/export.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.0/src/commands/export.ts)_
110+
_See code: [src/commands/export.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.1/src/commands/export.ts)_
110111

111112
## `hackmd-cli help [COMMAND]`
112113

@@ -152,7 +153,7 @@ EXAMPLE
152153
EeNHDGocSTi70ytMMGQaaQ Note2
153154
```
154155

155-
_See code: [src/commands/history.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.0/src/commands/history.ts)_
156+
_See code: [src/commands/history.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.1/src/commands/history.ts)_
156157

157158
## `hackmd-cli import [FILE]`
158159

@@ -163,19 +164,20 @@ USAGE
163164
$ hackmd-cli import [FILE]
164165
165166
OPTIONS
166-
-h, --help show CLI help
167+
-h, --help show CLI help
168+
-t, --team=team team to use
167169
168170
EXAMPLE
169-
$ hackmd-cli import /path/to/markdown/file.md
171+
$ hackmd-cli import /path/to/markdown/file.md --team=xxx
170172
171-
Your note is available at https://codimd.domain/note-url
173+
Your note is available at https://hackmd.io/note-url
172174
```
173175

174-
_See code: [src/commands/import.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.0/src/commands/import.ts)_
176+
_See code: [src/commands/import.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.1/src/commands/import.ts)_
175177

176178
## `hackmd-cli login`
177179

178-
Login HackMD instance from CLI
180+
Login to HackMD/CodiMD server from CLI
179181

180182
```
181183
USAGE
@@ -189,13 +191,13 @@ OPTIONS
189191
EXAMPLE
190192
$ hackmd-cli login
191193
192-
Enter your email: hello@codimd.domain
194+
Enter your email: hello@hackmd.io
193195
Enter your password: *******
194196
195197
Login as HMD successfully!
196198
```
197199

198-
_See code: [src/commands/login.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.0/src/commands/login.ts)_
200+
_See code: [src/commands/login.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.1/src/commands/login.ts)_
199201

200202
## `hackmd-cli logout`
201203

@@ -214,7 +216,36 @@ EXAMPLE
214216
You've logged out successfully
215217
```
216218

217-
_See code: [src/commands/logout.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.0/src/commands/logout.ts)_
219+
_See code: [src/commands/logout.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.1/src/commands/logout.ts)_
220+
221+
## `hackmd-cli teams`
222+
223+
HackMD Teams Command
224+
225+
```
226+
USAGE
227+
$ hackmd-cli teams
228+
229+
OPTIONS
230+
-h, --help show CLI help
231+
-x, --extended show extra columns
232+
--columns=columns only show provided columns (comma-separated)
233+
--csv output is csv format [alias: --output=csv]
234+
--filter=filter filter property by partial string matching, ex: name=foo
235+
--no-header hide table header from output
236+
--no-truncate do not truncate output to fit screen
237+
--output=csv|json|yaml output in a more machine friendly format
238+
--sort=sort property to sort by (prepend '-' for descending)
239+
240+
EXAMPLE
241+
$ hackmd-cli teams
242+
243+
Path Name
244+
team1 Team 1
245+
my-awesome-team My Awesome Team
246+
```
247+
248+
_See code: [src/commands/teams.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.1/src/commands/teams.ts)_
218249

219250
## `hackmd-cli whoami`
220251

@@ -233,7 +264,7 @@ EXAMPLE
233264
You are logged in hackmd.io as {YOUR NAME} [user-id]
234265
```
235266

236-
_See code: [src/commands/whoami.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.0/src/commands/whoami.ts)_
267+
_See code: [src/commands/whoami.ts](https://github.com/hackmdio/hackmd-cli/blob/v1.1.1/src/commands/whoami.ts)_
237268
<!-- commandsstop -->
238269

239270
## `hackmd-cli` piping mode

oclif.manifest.json

-1
This file was deleted.

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "@hackmd/hackmd-cli",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"author": "HackMD Team",
55
"bin": {
66
"hackmd-cli": "./bin/run"
77
},
88
"bugs": "https://github.com/hackmdio/hackmd-cli/issues",
99
"dependencies": {
10-
"@hackmd/api": "^1.1.0",
10+
"@hackmd/api": "1.1.1",
1111
"@oclif/command": "^1.5.19",
1212
"@oclif/config": "^1.13.3",
1313
"@oclif/plugin-help": "^2.2.3",

src/commands/import.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default class Import extends Command {
88
static description = 'Create a note from markdown file'
99

1010
static examples = [
11-
`$ hackmd-cli import /path/to/markdown/file.md
11+
`$ hackmd-cli import /path/to/markdown/file.md --team=xxx
1212
1313
Your note is available at https://hackmd.io/note-url
1414
`,
@@ -20,14 +20,24 @@ Your note is available at https://hackmd.io/note-url
2020

2121
static flags = {
2222
help: flags.help({char: 'h'}),
23+
team: flags.string({
24+
char: 't',
25+
default: '',
26+
description: 'team to use',
27+
required: false
28+
})
2329
}
2430

2531
async run() {
26-
const {args} = this.parse(Import)
32+
const {args, flags} = this.parse(Import)
33+
34+
if (!args.file) {
35+
return this.log('No file path specified.')
36+
}
2737

2838
const content = fs.readFileSync(path.resolve(process.cwd(), args.file), 'utf-8')
2939
try {
30-
const url = await APIClient.newNote(content)
40+
const url = await APIClient.newNote(content, {team: flags.team})
3141
this.log(`Your note is available at ${url}`)
3242
} catch (err) {
3343
this.error(err)

src/commands/login.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ Login as HMD successfully!
6363
}
6464

6565
try {
66-
let success = false
6766
if (flags.ldap) {
68-
success = await APIClient.loginLdap(id, password)
67+
await APIClient.loginLdap(id, password)
6968
} else {
70-
success = await APIClient.login(id, password)
69+
await APIClient.login(id, password)
7170
}
72-
if (success) {
71+
72+
const login = await APIClient.isLogin()
73+
if (login) {
7374
return this.log('Login successfully')
7475
} else {
7576
this.log('Login failed, please ensure your credentials are set')

src/commands/teams.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import {Command, flags} from '@oclif/command'
2+
import cli from 'cli-ux'
3+
4+
import {APIClient} from '../api'
5+
6+
export default class Teams extends Command {
7+
static description = 'HackMD Teams Command'
8+
9+
static examples = [
10+
`$ hackmd-cli teams
11+
12+
Path Name
13+
team1 Team 1
14+
my-awesome-team My Awesome Team`,
15+
]
16+
17+
static flags = {
18+
help: flags.help({char: 'h'}),
19+
...cli.table.flags()
20+
}
21+
22+
async run() {
23+
if (!APIClient.enterprise) {
24+
return this.log('Teams command only works on HackMD EE instance')
25+
}
26+
27+
try {
28+
const teams = await APIClient.getTeams()
29+
30+
cli.table(teams, {
31+
path: {
32+
header: 'Path',
33+
},
34+
name: {}
35+
}, {
36+
printLine: this.log,
37+
...flags
38+
})
39+
} catch (err) {
40+
this.log('Fetch teams failed')
41+
this.error(err)
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)