Skip to content

Commit 996e4bb

Browse files
authored
v0.2.0 (#4)
1 parent a38d82b commit 996e4bb

File tree

5 files changed

+51
-17
lines changed

5 files changed

+51
-17
lines changed

.github/workflows/test.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,20 @@ jobs:
1919
- run: npm link matterbridge
2020
- run: npm run build
2121
- run: npm link
22-
- run: sudo chown -R root:wheel "$(npm prefix -g --silent)/lib/node_modules"
22+
- run: |
23+
mb-service -h
24+
mb-service --help
25+
- run: |
26+
mb-service -v
27+
mb-service --version
28+
- run: |
29+
sudo chown -R root:wheel "$(npm prefix -g --silent)/lib/node_modules"
30+
ls -la "$(npm prefix -g --silent)/lib"
2331
- run: sudo mb-service install
24-
- run: mb-service pid
25-
- run: launchctl print system/com.matterbridge
26-
- run: sleep 10 && curl http://localhost:8283/
27-
- run: test -w "$(npm prefix -g --silent)/lib/node_modules"
32+
- run: |
33+
test -w "$(npm prefix -g --silent)/lib/node_modules"
34+
ls -la "$(npm prefix -g --silent)/lib"
35+
- run: mb-service pid && launchctl print system/com.matterbridge
36+
- run: sleep 10
37+
- run: curl http://localhost:8283/
2838
- run: sudo mb-service uninstall

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ _This is currently experimental and only supports macOS with a default configura
88
% npm install -g matterbridge mb-service
99
1010
% mb-service
11-
Usage: mb-service <command>
11+
Usage: mb-service <command> [options]
12+
1213
Commands:
1314
install Install the Matterbridge service
1415
uninstall Uninstall the Matterbridge service
@@ -18,6 +19,10 @@ Commands:
1819
pid Get the process id of the Matterbridge service
1920
tail Tail the Matterbridge log file
2021
22+
Options:
23+
-h, --help
24+
-v, --version
25+
2126
% sudo mb-service install
2227
Matterbridge Service Installed!
2328
Starting Matterbridge Service...

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mb-service",
33
"displayName": "Matterbridge Service Command",
4-
"version": "0.1.0",
4+
"version": "0.2.0",
55
"description": "A service management command-line utility for Matterbridge, inspired by Homebridge's 'hb-service'.",
66
"keywords": [
77
"matter",

src/mb-service.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
11
#!/usr/bin/env node
22

3+
import { readFileSync } from 'node:fs';
34
import { platform } from 'node:os';
45
import { parseArgs } from 'node:util';
56
import { MacPlatform } from './mac.js';
67
import { PlatformCommands } from './platform.js';
78

89
async function main() {
9-
const { positionals } = parseArgs({
10+
const args = parseArgs({
1011
args: process.argv.slice(2),
11-
options: { },
12+
options: {
13+
help: { type: 'boolean', short: 'h' },
14+
version: { type: 'boolean', short: 'v' } },
15+
strict: false,
1216
allowPositionals: true
1317
});
1418

19+
if (args.values.help) {
20+
help();
21+
process.exit(0);
22+
}
23+
24+
if (args.values.version) {
25+
const packageJson = readFileSync(new URL('../package.json', import.meta.url), 'utf8');
26+
const packageInfo = JSON.parse(packageJson);
27+
console.log(packageInfo.version);
28+
process.exit(0);
29+
}
30+
1531
let platformCommands: PlatformCommands;
1632
switch (platform()) {
1733
case 'darwin':
1834
platformCommands = new MacPlatform();
1935
break;
20-
// case 'linux':
21-
// platformCommands = new LinuxPlatform();
22-
// break;
2336
default:
24-
console.log('Platform not supported:', platform());
37+
console.error('Platform not supported:', platform());
2538
process.exit(2);
2639
}
2740

28-
const command = positionals[0];
41+
const command = args.positionals[0];
2942
switch (command) {
3043
case 'install':
3144
platformCommands.install();
@@ -67,7 +80,8 @@ async function main() {
6780
}
6881

6982
function help() {
70-
console.log('Usage: mb-service <command>');
83+
console.log('Usage: mb-service <command> [options]');
84+
console.log('');
7185
console.log('Commands:');
7286
console.log(' install Install the Matterbridge service');
7387
console.log(' uninstall Uninstall the Matterbridge service');
@@ -76,6 +90,11 @@ function help() {
7690
console.log(' restart Restart the Matterbridge service');
7791
console.log(' pid Get the process id of the Matterbridge service');
7892
console.log(' tail Tail the Matterbridge log file');
93+
console.log('');
94+
console.log('Options:');
95+
console.log(' -h, --help');
96+
console.log(' -v, --version');
97+
console.log('');
7998
}
8099

81100
main().catch(err => console.error(err));

0 commit comments

Comments
 (0)