-
-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): add function delete (#664)
- Loading branch information
Showing
2 changed files
with
37 additions
and
18 deletions.
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 |
---|---|---|
@@ -1,62 +1,68 @@ | ||
import { Command, program } from "commander" | ||
import { create, exec, list, pullAll, pullOne, pushAll, pushOne } from "../../action/function" | ||
import { create, del, exec, list, pullAll, pullOne, pushAll, pushOne } from "../../action/function" | ||
import { checkApplication, checkFunctionDebugToken } from "../../common/hook" | ||
|
||
export function command(): Command { | ||
const cmd = program.command('func') | ||
.hook('preAction', () => { | ||
checkApplication() | ||
}) | ||
checkApplication() | ||
}) | ||
|
||
cmd.command('create <funcName>') | ||
.description('Create function') | ||
.description('create function') | ||
.option('-w --websocket', 'enable websocket', true) | ||
.option('-m --methods <items...>', 'http methods', ['GET', 'POST']) | ||
.option('-t --tags <items...>', 'tags', []) | ||
.option('-d --description <description>', 'description', '') | ||
.action((funcName, options) => { | ||
create(funcName, options) | ||
}) | ||
|
||
|
||
cmd.command('del <funcName>') | ||
.description('del function') | ||
.action((funcName) => { | ||
del(funcName) | ||
}) | ||
|
||
cmd.command('list') | ||
.description('List application') | ||
.action(() => { | ||
list() | ||
}) | ||
|
||
cmd.command('pull') | ||
.argument('[funcName]', 'funcName') | ||
.description('Pull function, if funcName does not exist, pull all') | ||
.action((funcName) => { | ||
if (funcName) { | ||
pullOne(funcName) | ||
} else { | ||
} else { | ||
pullAll() | ||
} | ||
}) | ||
|
||
cmd.command('push') | ||
.argument('[FuncName]', 'funcName') | ||
.description('Push function, if funcName does not exist, push all') | ||
.description('push function, if funcName does not exist, push all') | ||
.action((funcName) => { | ||
if (funcName) { | ||
pushOne(funcName) | ||
} else { | ||
} else { | ||
pushAll() | ||
} | ||
}) | ||
|
||
cmd.command('exec <funcName>') | ||
.description('Exec function') | ||
.option('-l --log <count>', 'print log') | ||
.option('-r --requestId', 'print requestId', false) | ||
.hook('preAction', () => { | ||
.hook('preAction', () => { | ||
checkFunctionDebugToken() | ||
}) | ||
.action((funcName, options) => { | ||
exec(funcName, options) | ||
}) | ||
|
||
|
||
return cmd | ||
} |