UNPKG

1.41 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3const fs = require('fs');
4const path = require('path');
5const server = require("./server.js");
6const { spawn } = require('child_process');
7
8let commands = [{
9 command: "start",
10 help: "Start server instance",
11 aliases: [],
12 handler: () => {
13 server.start();
14 }
15}, {
16 command: "restart",
17 help: "Restart server instance",
18 aliases: [],
19 handler: () => {
20 server.restart();
21 }
22}, {
23 command: "stop",
24 help: "Stop server instance",
25 aliases: [],
26 handler: () => {
27 server.stop();
28 }
29}, {
30 command: "update",
31 help: "Update server instance",
32 aliases: [],
33 handler: () => {
34 server.update();
35 }
36}, {
37 command: "reload",
38 help: "Reload server config",
39 aliases: [],
40 handler: () => {
41 server.reload();
42 }
43}, {
44 command: "version",
45 help: "Show the version.",
46 aliases: ['-v', '--v', '-version', '--version'],
47 handler: () => {
48 server.version();
49 }
50}, {
51 command: "help",
52 help: "Show this screen.",
53 aliases: ['-h', '--h', '-help', '--help'],
54 handler: () => {
55 server.help(commands);
56 }
57}];
58
59let command = process.argv[2];
60
61(commands.find(schema => schema.command === command || schema.aliases.includes(command)) || commands.find(schema => schema.command === 'help')).handler();
\No newline at end of file