1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-21 21:09:22 +00:00

Can show command line help

This commit is contained in:
Pierre HUBERT 2020-05-25 18:21:37 +02:00
parent e4ca702af8
commit a3f0b86fea
2 changed files with 30 additions and 1 deletions

16
src/help.ts Normal file
View File

@ -0,0 +1,16 @@
/**
* Command-line usage help
*
* @author Pierre Hubert
*/
export function showHelp() {
console.info(
"Usage:\n" +
"* server (default) : Start the API server\n" +
"* help : Show this message\n" +
"* migration [mig_id] : Start a migration"
);
process.exit(0);
}

View File

@ -1,6 +1,7 @@
import { ConfigurationHelper } from "./helpers/ConfigHelper";
import { DatabaseHelper } from "./helpers/DatabaseHelper";
import { startServer } from "./server";
import { showHelp } from "./help";
/**
* Main project script
@ -20,6 +21,18 @@ async function init() {
console.info("Connect to database");
await DatabaseHelper.connect();
const action = process.argv.length < 4 ? "server" : process.argv[3];
switch(action) {
case "help":
showHelp();
break;
case "server":
await startServer();
break;
}
}
init();