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:
parent
e4ca702af8
commit
a3f0b86fea
16
src/help.ts
Normal file
16
src/help.ts
Normal 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);
|
||||
}
|
15
src/main.ts
15
src/main.ts
@ -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();
|
||||
|
||||
await startServer();
|
||||
const action = process.argv.length < 4 ? "server" : process.argv[3];
|
||||
|
||||
switch(action) {
|
||||
case "help":
|
||||
showHelp();
|
||||
break;
|
||||
|
||||
case "server":
|
||||
await startServer();
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
init();
|
Loading…
Reference in New Issue
Block a user