-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* eslint-disable no-console */ | ||
import { stripIndent as indent } from 'common-tags'; | ||
import arg from 'arg'; | ||
import { flags, safePairs } from 'cli-belt'; | ||
import { raise as command } from '~/public'; | ||
|
||
export default async function list(argv: string[]): Promise<void> { | ||
const help = indent` | ||
Usage: | ||
$ kpo :raise [options] | ||
Raises kpo tasks to package.json | ||
Options: | ||
--confirm Prompt for changes confirmation before performing a write operation | ||
--dry Dry run | ||
--fail Fails if there are any changes to be made on dry mode, or if the user cancels the action when confirmation is required | ||
-h, --help Show help | ||
`; | ||
|
||
const types = { | ||
'--confirm': Boolean, | ||
'--dry': Boolean, | ||
'--fail': Boolean, | ||
'--help': Boolean | ||
}; | ||
|
||
const { options, aliases } = flags(help); | ||
safePairs(types, options, { fail: true, bidirectional: true }); | ||
Object.assign(types, aliases); | ||
const cmd = arg(types, { argv, permissive: false, stopAtPositional: true }); | ||
|
||
if (cmd['--help']) return console.log(help); | ||
if (cmd._.length) throw Error('Unknown command: ' + cmd._[0]); | ||
|
||
return command.fn({ | ||
confirm: cmd['--confirm'], | ||
dry: cmd['--dry'], | ||
fail: cmd['--fail'] | ||
}); | ||
} |