-
Notifications
You must be signed in to change notification settings - Fork 6
/
cli.js
executable file
·85 lines (79 loc) · 1.76 KB
/
cli.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env node
const bg = require('./')
const cliclopts = require('cliclopts')
const minimist = require('minimist')
const pkg = require('./package.json')
const allowedOptions = [
{
name: 'outfile',
abbr: 'o',
help: 'Location to save image. (default: ~/Pictures/himawari-images/$TIMESTAMP.jpg)'
},
{
name: 'zoom',
abbr: 'z',
help: 'The zoom level of the image. Can be 1-5.',
default: 2
},
{
name: 'date',
abbr: 'd',
help: 'Time of the picture desired. Can also be "latest".',
default: 'latest'
},
{
name: 'infrared',
abbr: 'i',
help: 'Capture picture on the infrared spectrum.',
boolean: true,
default: false
},
{
name: 'parallel',
abbr: 'p',
help: 'Parallelize downloads for increased speeds (can be CPU intensive).',
boolean: true,
default: true
},
{
name: 'screen',
abbr: 's',
help: 'Screen to set the wallpaper on (macOS only). Options: "all", "main", screen index.',
default: 'main'
},
{
name: 'scale',
help: 'Scaling method (macOS only). Options: "auto", "fill", "fit", "stretch", "center".',
default: 'fit'
},
{
name: 'version',
abbr: 'v',
help: 'Show version information.',
boolean: true
},
{
name: 'help',
abbr: 'h',
help: 'Show help.',
boolean: true
}
]
const opts = cliclopts(allowedOptions)
const argv = minimist(process.argv.slice(2), opts.options())
if (argv.version) {
console.log(pkg.version)
process.exit()
}
if (argv.help) {
console.log()
console.log('Usage: himawari-bg [options]')
console.log()
opts.print()
console.log()
console.log('report an issue: ' + pkg.bugs.url)
console.log()
console.log('himawari-bg@%s %s', pkg.version, __dirname)
process.exit()
}
bg(argv)