TypeScirpt Interactive CLI Builder
npm install tsicliTypeScirpt Interactive CLI Builder
tsicli can make it easy to manage complex arguments of CLI application.
tsicli is setup and operate through the following process.
- Define types you can use in the arguments.
- Define arguments.
- Define runners matching with arguments you defined.
- If input values can't fulfill the arguments, then tsicli provides autocomplete prompt (like fzf) .
``typescriptnpm
$ npm install --save tsicli
Setup & Usage

`typescript
import { tsicli } from "tsicli";tsicli(process.argv, {
/ Defining types /
types: {
"#name": "string",
"#recordIds": "number[]",
"#yesOrNo": "boolean",
},
/ Defining args /
args: [
["practice", "name", "#name"],
["practice", "records", "#recordIds"],
["practice", "question", "#yesOrNo"],
["practice", "single"],
["action", "subAction1"],
["action", "subAction2"],
],
/ Defining runners /
runners: {
practice_name,
practice_records,
practice_question,
practice_single,
action_subAction1,
action_subAction2,
},
});
`Examples
$3
`typescript
tsicli(process.argv, {
/ Defining types /
types: {},
/ Defining args /
args: [["practice", "single"]],
/ Defining runners /
runners: {
practice_single,
},
});
`$3
`typescript
tsicli(process.argv, {
/ Defining types /
types: {
"#name": "string",
"#recordIds": "number[]",
"#yesOrNo": "boolean",
},
/ Defining args /
args: [
["practice", "name", "#name"],
["practice", "records", "#recordIds"],
["practice", "question", "#yesOrNo"],
],
/ Defining runners /
runners: {
practice_name,
practice_records,
practice_question,
},
});
`| Primitive Type | Note |
| -------------- | ------------------------------------ |
| string | String |
| string[] | String List (separated by comma
,) |
| number | Number |
| number[] | Number List (separated by comma ,) |
| boolean | Boolean (it prompts y/n) |$3
You can use
PromptObj to type definition.
For more details in PromptObj, you can find it prompts package document.`typescript
tsicli(process.argv, {
/ Defining types /
types: {
"#smdId": {
type: "autocomplete",
name: "#smdId",
message: "Please input #smdId",
choices: [
{ title: "Brand", value: "Brand" },
{ title: "Category", value: "Category" },
{ title: "Product", value: "Product" },
],
},
"#recordIds": "number[]",
},
/ Defining args /
args: [["fixture", "import", "#smdId", "#recordIds"]],
/ Defining runners /
runners: {
fixture_import,
},
});
``