-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·36 lines (27 loc) · 773 Bytes
/
index.js
File metadata and controls
executable file
·36 lines (27 loc) · 773 Bytes
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
#!/usr/bin/env node
var makeTable = require('./makeTable.js')
var fs = require('fs')
var key = process.argv[2]
var save = false
if (process.argv[3] && process.argv[3].match('--save')) {
save = true
}
if (key && !save) {
makeTable(key, function callback (err, table) {
if (err !== null) return console.error(err)
console.log(table)
})
}
if (key && save) {
makeTable(key, function callback (err, table) {
if (err !== null) return console.error(err)
fs.writeFile('table.md', table.toString(), function (err) {
if (err) return console.error(err)
})
console.log('Table has been created and saved')
})
}
if (!key) {
console.log('To use: `$ sheetdown SPREADSHEETKEY --save`\n' +
'Or: `$ sheetdown SPREADSHEETKEY | pbcopy')
}