Skip to content
This repository was archived by the owner on Feb 3, 2022. It is now read-only.

Commit 0cb39fc

Browse files
committed
Refactor default command out to proper command module.
1 parent 776d715 commit 0cb39fc

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/cli.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const yargs = require('yargs');
2-
const { handler, describe, cliInfo } = require('./command');
2+
const DefaultCommand = require('./command');
33

44
function cli(cwd) {
55
yargs.help();
@@ -9,19 +9,8 @@ function cli(cwd) {
99

1010
yargs.default('path', cwd);
1111

12-
yargs.usage(describe);
13-
yargs.command(
14-
'$0 <name>',
15-
describe,
16-
command => {
17-
command.positional('name', {
18-
describe: 'Name of your project.',
19-
type: 'string'
20-
});
21-
command.options(cliInfo.options);
22-
},
23-
argv => handler(argv)
24-
);
12+
yargs.usage(DefaultCommand.describe);
13+
yargs.command(DefaultCommand);
2514

2615
return yargs;
2716
}

src/command.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
const createTwilioFunction = require('./create-twilio-function');
1+
const handler = require('./create-twilio-function');
2+
3+
const command = '$0 <name>';
4+
const describe = 'Creates a new Twilio Function project';
25

36
const cliInfo = {
47
options: {
@@ -27,8 +30,18 @@ const cliInfo = {
2730
}
2831
};
2932

33+
const builder = command => {
34+
command.positional('name', {
35+
describe: 'Name of your project.',
36+
type: 'string'
37+
});
38+
command.options(cliInfo.options);
39+
};
40+
3041
module.exports = {
31-
describe: 'Creates a new Twilio Function project',
32-
handler: createTwilioFunction,
33-
cliInfo: cliInfo
42+
command,
43+
describe,
44+
handler,
45+
cliInfo,
46+
builder
3447
};

0 commit comments

Comments
 (0)