From ca1aad7e48c7cab7d33a3ecafab209c420ecb2d3 Mon Sep 17 00:00:00 2001 From: qxb3 Date: Mon, 9 May 2022 23:56:27 +0800 Subject: [PATCH 1/3] 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); From 1db2f8eeddbc930fb562bdf5f65137b8acf0c630 Mon Sep 17 00:00:00 2001 From: qxb3 Date: Tue, 10 May 2022 00:07:10 +0800 Subject: [PATCH 2/3] Changed to export function help --- src/commands/help.js | 2 +- src/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/help.js b/src/commands/help.js index 56381ae..f725d65 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -1,4 +1,4 @@ -export default function () { +export function help() { 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 6bed787..6971622 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ #!/usr/bin/env node import { init } from './commands/init.js'; -import help from './commands/help.js'; +import { help } from './commands/help.js'; const regex = /(?<=--|-)\w+/gm; const flags = process.argv.slice(2).join(' ').match(regex); From 55610140584b9974005da51a03b572fae58c70e9 Mon Sep 17 00:00:00 2001 From: qxb3 Date: Tue, 10 May 2022 01:07:46 +0800 Subject: [PATCH 3/3] Fix prettier issue --- src/commands/help.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/commands/help.js b/src/commands/help.js index f725d65..b808402 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -1,6 +1,3 @@ export function help() { - console.log( - 'This is sern cli help section\n\n' + - 'Fill me up later!' - ) + console.log('This is sern cli help section\n\n' + 'Fill me up later!'); }