From ca23d17670663b62e23849e2350deef208bfc100 Mon Sep 17 00:00:00 2001 From: qxb3 Date: Mon, 9 May 2022 23:56:27 +0800 Subject: [PATCH] feat: added help command --- src/commands/help.js | 6 ++++++ src/index.js | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/commands/help.js diff --git a/src/commands/help.js b/src/commands/help.js new file mode 100644 index 0000000..56381ae --- /dev/null +++ b/src/commands/help.js @@ -0,0 +1,6 @@ +export default function () { + console.log( + 'This is sern cli help section\n\n' + + 'Fill me up later!' + ) +} diff --git a/src/index.js b/src/index.js index 3bbfc4e..6bed787 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,8 @@ #!/usr/bin/env node import { init } from './commands/init.js'; +import help from './commands/help.js'; + const regex = /(?<=--|-)\w+/gm; const flags = process.argv.slice(2).join(' ').match(regex); @@ -12,7 +14,11 @@ const args = rawArgs .filter((e) => !/(--|-)\w+/gm.test(e)); const cmdName = args[0]; -const commands = new Map([['init', init]]); +const commands = new Map([ + ['help', help], + ['', help], + ['init', init], +]); const found = commands.get(cmdName);