This repository has been archived by the owner on Aug 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
cli.js
executable file
·109 lines (101 loc) · 2.73 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env node
var program = require('commander')
program.allowUnknownOption(true)
var commands = [{
command: 'default',
description: 'sets a raspbian back to default configuration',
action: './lib/default.js'
},
{
command: 'rename <hostname>',
description: 'changes hostname',
action: './lib/hostname.js'
},
{
command: 'wifi <ESSID> [password]',
description: 'connects to a wifi network',
action: './lib/wifi.js'
},
{
command: 'staticwifi <ip> <mask> <gateway> <dns>',
description: 'configures rpi wifi interface to a static ip address',
action: './lib/staticwifi.js'
},
{
command: 'ethernet <ip> <mask> <gateway> <dns>',
description: 'configures rpi network interface to a static ip address',
action: './lib/ethernet.js'
},
{
command: 'hotspot <ESSID> [password]',
description: 'creates a mobile hotspot',
action: './lib/hotspot.js'
},
{
command: 'expandfs',
description: 'expands the partition of the RPI image to the maximum of the SDcard',
action: './lib/expandfs.js'
},
{
command: 'detectrpi',
description: 'detects the hardware version of a raspberry pi',
action: './lib/detectrpi.js'
},
{
command: 'version',
description: 'returns the version of pirateship command',
action: './lib/version.js'
},
// {
// command: 'detectwifi',
// description: 'detect chipset of USB-Wifi dongle',
// action: './lib/detectwifi.js'
// },
{
command: 'password <password>',
description: 'change the password for `pi` user',
action: './lib/password.js'
},
{
command: 'sshkeyadd <public_key>',
description: 'add a public key to `pi` and `root` user\'s authorized_keys',
action: './lib/sshkeyadd.js'
},
{
command: 'container <none|docker|balena>',
description: 'enables (and start) the desired container',
action: './lib/container.js'
},
{
command: 'bluetooth <on|off>',
description: 'switches between bluetooth hotspot mode / regular bluetooth and starts the service',
action: './lib/bluetooth.js'
},
{
command: 'wificountry <country>',
description: 'changes the wifi country',
action: './lib/wificountry.js'
}
]
commands.sort((a, b) => {
a = a.command.split(" ")[0]
b = b.command.split(" ")[0]
return a.localeCompare(b);
});
commands.forEach(command => {
program
.command(command.command)
.description(command.description)
.action(require(command.action))
})
// default case
program
.command('*')
.description('temporary catch all')
.action(function(env) {
console.log('ERROR "%s" does not exist\npirateship --help', env);
});
if (process.argv.length == 2) {
process.argv.push('--help')
}
program.parse(process.argv);