diff --git a/src/help.ts b/src/help.ts new file mode 100644 index 0000000..e84fcce --- /dev/null +++ b/src/help.ts @@ -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); +} \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 850e632..f692c04 100644 --- a/src/main.ts +++ b/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(); \ No newline at end of file