{"_id":"@caiorafael/simple-cl","_rev":"2-927615de23baa73ad72b6b7b11af51a9","name":"@caiorafael/simple-cl","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@caiorafael/simple-cl","version":"1.0.0","description":"A simple lib for construction of command line interface - CLI. \r Compatibility with typescript","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1","lint":"npx eslint ./src","dev":"tsx ./src","build":"npx tsc"},"keywords":[],"author":{"name":"caiorafael"},"license":"ISC","devDependencies":{"@types/node":"^20.10.0","tsx":"^4.5.0","typescript":"^5.3.2"},"dependencies":{"esbuild":"^0.18.20","get-tsconfig":"^4.7.2","resolve-pkg-maps":"^1.0.0","undici-types":"^5.26.5"},"repository":{"type":"git","url":"git+https://github.com/caioRafael/simple-cl.git"},"bugs":{"url":"https://github.com/caioRafael/simple-cl/issues"},"homepage":"https://github.com/caioRafael/simple-cl#readme","_id":"@caiorafael/simple-cl@1.0.0","gitHead":"0b146a8bb3cacbb87ec43ffbf39207c59bdad3e4","_nodeVersion":"20.9.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-nU1/OFKzFncho5yGebFQGVw4rOqfUR98bin1FuC5WPThryue6NxvkRH9BY7vhu3JSZmeIRt8JLVSe2JqRk5T2Q==","shasum":"b71be95979192c4f6ca85ce3a4535d3b9a899143","tarball":"https://registry.npmjs.org/@caiorafael/simple-cl/-/simple-cl-1.0.0.tgz","fileCount":23,"unpackedSize":19296,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCU9so968UlQiAUrTcBUv3vxaVnI2uEMu6xvL5VffngEAIhAO3FMPKP0ShZOu4xywFvII92+ahNQOBG9d63n1rilcjO"}]},"_npmUser":{"name":"caiorafael","email":"caiorafaelrg@gmail.com"},"directories":{},"maintainers":[{"name":"caiorafael","email":"caiorafaelrg@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-cl_1.0.0_1701473761007_0.4136466898635969"},"_hasShrinkwrap":false},"1.0.1":{"name":"@caiorafael/simple-cl","version":"1.0.1","description":"A simple lib for construction of command line interface - CLI. \r Compatibility with typescript","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1","lint":"npx eslint ./src","dev":"tsx ./src","build":"npx tsc"},"keywords":[],"author":{"name":"caiorafael"},"license":"ISC","devDependencies":{"@types/node":"^20.10.0","tsx":"^4.5.0","typescript":"^5.3.2"},"dependencies":{"esbuild":"^0.18.20","get-tsconfig":"^4.7.2","resolve-pkg-maps":"^1.0.0","undici-types":"^5.26.5"},"repository":{"type":"git","url":"git+https://github.com/caioRafael/simple-cl.git"},"bugs":{"url":"https://github.com/caioRafael/simple-cl/issues"},"homepage":"https://github.com/caioRafael/simple-cl#readme","_id":"@caiorafael/simple-cl@1.0.1","gitHead":"93ff534188345f6a451432114952b38103a6ba12","_nodeVersion":"20.9.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-/EVXzH+Sb1L/CwGyfzEQBeiP6jl9ZYiX3jus4zBUJJ+PN6NpFQuxAti+TFhY6G63lKujUrpnoavwL3sJwtiIaA==","shasum":"b974e562d1f981dfbe6dfe2d3494ce165fe34e46","tarball":"https://registry.npmjs.org/@caiorafael/simple-cl/-/simple-cl-1.0.1.tgz","fileCount":23,"unpackedSize":19361,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCmyyplr0DKV1t1BCA9qmYno5O5RKQdAT7iYe8x5/URnQIgfSc4uucm+rNOyYwus55xItQEbRNd8eKesyuMzAFXAgc="}]},"_npmUser":{"name":"caiorafael","email":"caiorafaelrg@gmail.com"},"directories":{},"maintainers":[{"name":"caiorafael","email":"caiorafaelrg@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-cl_1.0.1_1701474622108_0.5513448565736081"},"_hasShrinkwrap":false},"1.0.2":{"name":"@caiorafael/simple-cl","version":"1.0.2","description":"A simple lib for construction of command line interface - CLI. \r Compatibility with typescript","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1","lint":"npx eslint ./src","dev":"tsx ./src","build":"npx tsc"},"keywords":[],"author":{"name":"caiorafael"},"license":"ISC","devDependencies":{"@types/node":"^20.10.0","tsx":"^4.5.0","typescript":"^5.3.2"},"dependencies":{"esbuild":"^0.18.20","get-tsconfig":"^4.7.2","resolve-pkg-maps":"^1.0.0","undici-types":"^5.26.5"},"repository":{"type":"git","url":"git+https://github.com/caioRafael/simple-cl.git"},"bugs":{"url":"https://github.com/caioRafael/simple-cl/issues"},"homepage":"https://github.com/caioRafael/simple-cl#readme","_id":"@caiorafael/simple-cl@1.0.2","gitHead":"b9e98728ca665b219866aa110099f33e0a553cb8","_nodeVersion":"20.9.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-qqdAdMny9+op+4GR0cMRsnMGk9jnyLT3/GhqqAbnfDCIYOmnKHB+VwMV8OG6veUxzMFw1CbtlFDPezBXHf2hCw==","shasum":"66743750c4e0c09658bb3273e60d0612553ec768","tarball":"https://registry.npmjs.org/@caiorafael/simple-cl/-/simple-cl-1.0.2.tgz","fileCount":23,"unpackedSize":19385,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFksREYlTpKb1m23j+2vGfkc8J/l+j4KbiQgHHtMjDtQAiEA/lyGYqvV1d1y6sfpuuPhJrWzZDiaY2YTLcXB6tb35Y4="}]},"_npmUser":{"name":"caiorafael","email":"caiorafaelrg@gmail.com"},"directories":{},"maintainers":[{"name":"caiorafael","email":"caiorafaelrg@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-cl_1.0.2_1701474950579_0.2981778619196014"},"_hasShrinkwrap":false}},"time":{"created":"2023-12-01T23:36:00.932Z","1.0.0":"2023-12-01T23:36:01.271Z","modified":"2023-12-01T23:55:50.981Z","1.0.1":"2023-12-01T23:50:22.306Z","1.0.2":"2023-12-01T23:55:50.812Z"},"maintainers":[{"name":"caiorafael","email":"caiorafaelrg@gmail.com"}],"description":"A simple lib for construction of command line interface - CLI. \r Compatibility with typescript","homepage":"https://github.com/caioRafael/simple-cl#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/caioRafael/simple-cl.git"},"author":{"name":"caiorafael"},"bugs":{"url":"https://github.com/caioRafael/simple-cl/issues"},"license":"ISC","readme":"# Simple CL\r\n\r\nA simple lib for construction of command line interface - CLI. \r\nCompatibility with typescript \r\n\r\n## Instalation\r\n\r\n```bash\r\nnpm install @caiorafael/simple-cl\r\n```\r\n\r\n## Usage\r\n\r\nimport lib\r\n\r\nwith typescript:\r\n\r\n```typescript\r\nimport { CommandLine } from '@caiorafael/simple-cl'\r\n```\r\n\r\nwith javascript:\r\n\r\n```javascript\r\nconst { CommandLine } = rquire('@caiorafael/simple-cl')\r\n```\r\n\r\n## Set cli's informations\r\n\r\n```typescript\r\nconst args = process.argv.slice(2)\r\n\r\nconst command = new CommandLine()\r\n\r\ncommandLine\r\n    .setName('cli-name')\r\n    .setVersion('1.0.0')\r\n    .setDescription('a new command line interface')\r\n\r\ncommandLine.parse(args)\r\n```\r\n\r\nFrom now on, it's possible to send some commands to your CLI, such as --help or -h to view the help text on your CLI, and --version or -v to view the CLI version.\r\n\r\n## Add new command\r\n\r\nTo add new commands to your CLI, you can use the 'addCommand' function. Along with this function, you can also add its description using the 'setDescription' function, and you can add flags with the 'addOption' command. Finally, you should add the action for this command using the 'setAction' function.\r\n\r\n```typescript\r\ncommandLine\r\n    .addCommand('command')\r\n    .setDsescription('set description')\r\n    .addOption({\r\n        flag: '--flag',\r\n        alias: '-f',\r\n        description: 'flag option',\r\n        value: 'flag-value'\r\n    })\r\n    .setAction(() => console.log('Hello world!'))\r\n```\r\n\r\nTo add the flags, you have some options. The 'flag' and 'alias' attributes can be provided without the ' -- ' and ' - ' prefixes, but they must be sent with these prefixes in the command line. If you don't want the flags to come with any default values, simply don't provide any value in the 'value' attribute; it is optional.\r\n\r\n## Action Options\r\n\r\nThe actions can receive two parameters: the first one is the argument that can be sent by the user after calling the command, and the second one is a JSON object representing the flags and their values, either default or sent with the respective flags. \r\n\r\n\r\n```typescript\r\ncommandLine\r\n    .addCommand('command')\r\n    .setDsescription('set description')\r\n    .addOption({\r\n        flag: '--flag',\r\n        description: 'flag option',\r\n    })\r\n    .setAction((arg, options) => console.log(arg, options))\r\n```\r\n\r\nThe values sent above are only the flags or aliases that are registered in the command and are sent in the command line.\r\n\r\n## Observation\r\n\r\nIf you are building your CLI with TypeScript and using [ts-node](https://typestrong.org/ts-node/) or [tsx](https://www.npmjs.com/package/tsx) to execute your code during tests, it's important to add -- before every command you are sending. This is because there are TypeScript commands that use the same syntax, and by adding this small snippet, it understands that it should take all the arguments sent.\r\n\r\n```bash\r\ntsx script.ts -- comando --flag\r\n```","readmeFilename":"README.md"}