-
Notifications
You must be signed in to change notification settings - Fork 0
/
dreamwidth-js-entry-post
executable file
·38 lines (31 loc) · 1.1 KB
/
dreamwidth-js-entry-post
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env node
'use strict';
let program = require('commander')
let concat = require('concat-stream')
let cli = require('./lib/cli')
let dw = require('./lib/dreamwidth')
program
.usage('[options] < file.html')
.option('-s, --subject <string>', 'entry title')
.option('-d, --date <string>', 'YYYY-MM-DD HH:MM')
.option('-t, --tags <string>', 'tags separated by commas')
.option('--backdated', "don't show up on people's friends lists")
.option('--security <string>', 'private, friends, public', 'private')
.parse(process.argv)
process.stdin.pipe(concat( input => {
input = input.toString()
if (!input.trim().length) cli.errx('invalid input')
let jrn = new dw.Dreamwidth(process.env.dw_login, process.env.dw_password)
jrn.debug = !!process.env.dw_debug
program.date = new Date(Date.parse(program.date) || Date.now())
jrn.entry_post(program.subject, program.date, program.tags,
input, {
opt_backdated: program.backdated,
security: program.security
})
.then( val => {
console.log(val)
}).catch( err => {
cli.abort(err)
})
}))