-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (31 loc) · 940 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env node
const yargs = require("yargs");
const fs = require('fs');
yargs
.scriptName("github-actions-test")
.usage('$0 <cmd> [args]')
.command('hello [name]', "prints a greeting", (yargs) => {
yargs.positional('name', {
type: 'string',
default: 'Kevin',
describe: 'the name to say hello to'
})
}, function (argv) {
console.log('Hi,', argv.name, "!")
})
.command('print [message] [file]', "prints message to a file", (yargs) => {
yargs.positional('message', {
type: 'string',
default: 'Hi, Kevin',
describe: 'the message to print'
}),
yargs.positional('file', {
type: 'string',
default: 'out.txt',
describe: 'the file to print to'
})
}, function (argv) {
fs.writeFileSync(argv.file, argv.message);
})
.help()
.argv