项目作者: MamoruDS

项目描述 :
Simple cli arguments parser written in typescript for node/Deno
高级语言: TypeScript
项目地址: git://github.com/MamoruDS/cap.git
创建时间: 2021-01-17T12:11:21Z
项目社区:https://github.com/MamoruDS/cap

开源协议:MIT License

下载


cap

Simple cli arguments parser written in TypesScript for node/Deno

npm

Installation

nodejs

  1. npm i @mamoruds/cap

Deno

  1. import { Cap } from 'https://deno.land/x/cap/cap-deno.ts'

Usage

  1. import { Cap } from '@mamoruds/cap'
  2. const cap = new Cap({
  3. name: {
  4. alias: 'n',
  5. type: 'string',
  6. optional: false,
  7. about: 'some description about field "name"',
  8. },
  9. age: {
  10. type: 'string',
  11. optional: true,
  12. about: 'some description about field "age"',
  13. },
  14. silent: {
  15. alias: 's',
  16. type: 'boolean',
  17. optional: true,
  18. default: true,
  19. about: 'enable/disable silent',
  20. },
  21. })
  22. .about('cap-js-example-node')
  23. .parse(process.argv.slice(2))
  24. console.log(cap)
  25. // $ node script.js -n mamoru --no-silent
  26. // or using Deno
  27. // $ deno run script.js -n mamoru --no-silent
  28. // output
  29. // { name: 'mamoru', silent: false, age: undefined }

License

MIT © MamoruDS