{"id":21850375,"url":"https://github.com/lillallol/fn-to-cli","last_synced_at":"2026-05-03T22:34:11.558Z","repository":{"id":57239483,"uuid":"344873829","full_name":"lillallol/fn-to-cli","owner":"lillallol","description":"Converts typescript functions to node CLI executable.","archived":false,"fork":false,"pushed_at":"2021-05-14T14:58:42.000Z","size":962,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-27T02:57:55.338Z","etag":null,"topics":["cli","cli-generator"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lillallol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-05T16:47:05.000Z","updated_at":"2021-09-28T16:25:48.000Z","dependencies_parsed_at":"2022-08-30T00:11:21.209Z","dependency_job_id":null,"html_url":"https://github.com/lillallol/fn-to-cli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lillallol/fn-to-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lillallol%2Ffn-to-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lillallol%2Ffn-to-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lillallol%2Ffn-to-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lillallol%2Ffn-to-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lillallol","download_url":"https://codeload.github.com/lillallol/fn-to-cli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lillallol%2Ffn-to-cli/sbom","scorecard":{"id":589848,"data":{"date":"2025-08-11","repo":{"name":"github.com/lillallol/fn-to-cli","commit":"7d232960d1b401dea2bb0e8e2a069ce1785b738c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/9 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"36 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-hxwm-x553-x359","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22","Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp","Warn: Project is vulnerable to: GHSA-px4h-xg32-q955","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T21:34:34.000Z","repository_id":57239483,"created_at":"2025-08-20T21:34:34.000Z","updated_at":"2025-08-20T21:34:34.000Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32587821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"ssl_error","status_checked_at":"2026-05-03T22:09:10.534Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cli-generator"],"created_at":"2024-11-28T00:17:15.719Z","updated_at":"2026-05-03T22:34:11.541Z","avatar_url":"https://github.com/lillallol.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fn-to-cli\n\n## Table of contents\n\n\u003c!--#region toc--\u003e\n\n- [fn-to-cli](#fn-to-cli)\n    - [Table of contents](#table-of-contents)\n    - [Installation](#installation)\n    - [Description](#description)\n    - [Code coverage](#code-coverage)\n    - [Quick start](#quick-start)\n    - [Example](#example)\n    - [Documentation](#documentation)\n    - [Motivation](#motivation)\n    - [Contributing](#contributing)\n    - [Changelog](#changelog)\n        - [2.0.3](#203)\n        - [2.0.2](#202)\n        - [2.0.1](#201)\n        - [2.0.0](#200)\n        - [1.0.0](#100)\n    - [License](#license)\n\n\u003c!--#endregion toc--\u003e\n\n## Installation\n\n```bash\nnpm install fn-to-cli\n```\n\n## Description\n\nThis module converts typescript functions to CLI.\n\n## Code coverage\n\nCode coverage is around 90%.\n\n## Quick start\n\nFor a quick start:\n\n0.  execute from terminal:\n\n    ```bash\n    npx fn-to-cli --help;\n    ```\n\n1.  add `@CLI` JSDoc tag comment to the functions you want to convert to CLI\n2.  compile your typescript project to javascript project\n3.  execute from terminal:\n\n    ```bash\n    npx fn-to-cli;\n    ```\n\nIf something goes wrong you will receive helpful error messages that will guide you on resolving the error.\n\n## Example\n\n1.  Create a new folder and set it as your current working directory:\n\n    ```bash\n    mkdir example; cd ./example;\n    ```\n\n2.  Create `./package.json` with the following content:\n\n    \u003c!--#region example-package !./example/package.json--\u003e\n\n    ```json\n    {\n        \"name\": \"some-random-package-name\",\n        \"version\": \"1.0.0\",\n        \"private\": true,\n        \"main\": \"./dist/index.js\",\n        \"bin\": \"bin/bin.js\",\n        \"scripts\": {\n            \"build-ts\": \"rm -rf ./dist; npx tsc\",\n            \"build-bin\": \"rm -rf ./bin; npx fn-to-cli\",\n            \"build\": \"npm run build-ts \u0026\u0026 npm run build-bin\",\n            \"test\": \"jest\"\n        },\n        \"devDependencies\": {\n            \"jest\": \"^26.6.3\",\n            \"typescript\": \"^4.2.3\"\n        },\n        \"dependencies\": {\n            \"fn-to-cli\": \"file:..\"\n        }\n    }\n    \n    ```\n\n    \u003c!--#endregion example-package--\u003e\n\n    Notice the bin property in `./package.json`. This is used by `fn-to-cli` as a path to output the generated CLI.\n\n3.  Delete from `./package.json` the line:\n\n    ```bash\n    \"fn-to-cli\": \"../\"\n    ```\n\n4.  Install `fn-to-cli`:\n\n    ```bash\n    npm install fn-to-cli;\n    ```\n\n    this will also install the rest of the dependencies.\n\n5.  Create `./tsconfig.json` with the following content:\n\n    \u003c!--#region example-tsconfig !./example/tsconfig.json--\u003e\n\n    ```json\n    {\n        \"compilerOptions\": {\n            \"rootDir\": \"./src\",\n            \"outDir\": \"./dist\",\n            \"module\": \"CommonJS\",\n            \"target\": \"ESNext\",\n            \"declaration\": true\n        },\n        \"exclude\": [\n            \"node_modules\"\n        ]\n    }\n    ```\n\n    \u003c!--#endregion example-tsconfig--\u003e\n\n6.  Create `./src/index.ts` with the following content:\n\n    \u003c!--#region example-tsconfig !./example/src/index.ts--\u003e\n\n    ```ts\n    export { foo } from \"./foo\";\n    \n    ```\n\n    \u003c!--#endregion example-tsconfig--\u003e\n\n7.  Create `./src/foo.ts` with the following content:\n\n    \u003c!--#region example-tsconfig !./example/src/foo.ts--\u003e\n\n    ```ts\n    /**\n     * Some tag less description for command foo.\n     * @CLI\n     */\n    export function foo(_: {\n        /**\n         * @description\n         * Some tag full description for option `a` of command `foo`.\n         */\n        a: string;\n        /**\n         * Some tag less description for option `b` of command `foo`.\n         * @default true\n         * @flag V\n         */\n        b?: boolean;\n    }): void {\n        const { a } = _;\n        let { b } = _;\n        if (b === undefined) b = true;\n        console.log(`foo executed with a = \"${a}\", b = ${b}`);\n    }\n    \n    ```\n\n    \u003c!--#endregion example-tsconfig--\u003e\n\n8.  Create `./src/bar/bar.ts` with the following content:\n\n    \u003c!--#region example-tsconfig !./example/src/bar/bar.ts--\u003e\n\n    ```ts\n    /**\n     * @description\n     * Some tag full description for command `bar`.\n     * @CLI baz\n     */\n    export default function bar(_: {\n        /**\n         * Some tag less description for option `c` of command `bar`.\n         */\n        c: boolean;\n        /**\n         * Some tag less description for option `d` of command `bar`.\n         * @private\n         * @default true\n         */\n        d?: boolean;\n    }): void {\n        const { c } = _;\n        let { d } = _;\n        if (d === undefined) d = true;\n        console.log(`bar executed with c = ${c}, d = ${d}`);\n    }\n    \n    ```\n\n    \u003c!--#endregion example-tsconfig--\u003e\n\n9.  Execute:\n\n    ```bash\n    npm run build;\n    ```\n\n    This command does two things:\n\n    -   builds typescript to javascript\n    -   generates the CLI\n\n10. Now you can use the generated CLI. Here are some examples:\n\n    \u003c!--#region bash-execute !./example/toExecute.bash--\u003e\n\n    ```bash\n    node ./bin/bin.js foo --a \"'hello'\";\n    node ./bin/bin.js foo --a \"'hello'\" -V \"false\";\n    node ./bin/bin.js baz --c \"false\";\n    ```\n\n    \u003c!--#endregion bash-execute--\u003e\n\n## Documentation\n\nExecute the following command:\n\n```bash\nnpx fn-to-cli --help\n```\n\nto get the CLI documentation:\n\n\u003c!--#region documentation !./documentation.txt--\u003e\n\n```txt\nCLI syntax:\n\n  fn-to-cli fnToCLI? [[--\u003coption\u003e | -\u003cflag\u003e] \u003cvalue\u003e]#\n\nDescription:\n\n  Converts typescript functions to CLI.\n\nNon required options:\n\n  -t --pathToTsconfig    : string  = \"./tsconfig.json\"  Path to `tsconfig.json`.\n  -p --pathToPackageJson : string  = \"./package.json\"   Path to `package.json`.\n  -s --strict            : boolean = false              For one command CLI, it is optional to write the command name when using the CLI. Give `true` to disable that.\n\n```\n\n\u003c!--#endregion documentation--\u003e\n\nThe CLI generator works by searching deeply in the directory defined by the property `compilerOptions.outDir` of `tsconfig.json`, for all the `.d.ts` files that have functions with `@CLI` JSDoc tag. These functions become commands to the generated CLI.\n\nThe generated CLI is saved to the path defined by the `bin` property of `package.json`, and imports js functions from the directories `compilerOptions.outDir`, and `node_modules`, so it will not work if these folders are missing or moved.\n\nEach function with the `@CLI` JSDoc tag has to:\n\n1.  have a single parameter that is `TypeLiteral`, for example:\n\n    ```\n    {\n        param1 : string,\n        param2 : boolean\n    }\n    ```\n\n2.  be a function declaration statement, for example:\n\n    -   incorrect:\n\n        ```ts\n        const foo = () =\u003e {\n            //some code\n        };\n        ```\n\n    -   correct:\n\n        ```ts\n        function foo() {\n            //some code\n        }\n        ```\n\n3.  be named or default exported\n4.  have name\n5.  have description in its JSDoc comment via a `@description` tag or tag-less\n6.  same for each property in its parameter type signature\n7.  have `@default` JSDoc tag with initialization value for each optional parameter\n8.  be inside the `rootDir` directory as defined by the provided `tsconfig.json`\n9.  be in a `.ts` file\n\nThe functions can have:\n\n1.  `@flag` JSDoc tag for any of its properties. It has to have a single letter as a value which can be used instead of the parameter names in the CLI.\n2.  `@cliPrivate` JSDoc tag for any of its optional properties. These properties will not be visible in the documentation of the CLI and will not receive a value even if the user of the CLI provides one for them.\n\n## Motivation\n\nA typescript function with JSDoc comments, contains all the necessary information to be converted automatically to a cli. Why would anyone waste their time doing the conversion manually? Automating that is the only maintainable solution.\n\n## Contributing\n\nI am open to suggestions/pull request to improve this program.\n\nYou will find the following commands useful:\n\n-   Clones the github repository of this project:\n\n    ```bash\n    git clone https://github.com/lillallol/fn-to-cli\n    ```\n\n-   Installs the node modules (nothing will work without them):\n\n    ```bash\n    npm install\n    ```\n\n-   Tests the source code:\n\n    ```bash\n    npm run test-src\n    ```\n\n-   Tests the example in the example folder:\n\n    ```bash\n    npm run test-example\n    ```\n\n-   Lints the source folder using typescript and eslint:\n\n    ```bash\n    npm run lint\n    ```\n\n-   Builds the typescript code from the `./src` folder to javascript code in `./dist`:\n\n    ```bash\n    npm run build-ts\n    ```\n\n-   Creates the CLI executable of this program in `./bin/bin.js`:\n\n    ```bash\n    npm run build-bin\n    ```\n\n    Make sure that the `./dist` exists when you execute this command, otherwise it will not work.\n\n-   Injects in place the generated toc and imported files to `README.md`:\n\n    ```bash\n    npm run build-md\n    ```\n\n-   Checks the project for spelling mistakes:\n\n    ```bash\n    npm run spell-check\n    ```\n\n    Take a look at the related configuration `./cspell.json`.\n\n-   Checks `./src` for dead typescript files:\n\n    ```bash\n    npm run dead-files\n    ```\n\n    Take a look at the related configuration `./unimportedrc.json`.\n\n## Changelog\n\n### 2.0.3\n\nRemoved package name and version from the CLI generated documentation.\n\n### 2.0.2\n\nRemoved the unnecessary quotation marks from the default values in the CLI generated documentation.\n\n### 2.0.1\n\n**bug fixes:**\n\nMoved `typescript-is` from development dependencies to dependencies.\n\n### 2.0.0\n\n**breaking changes**:\n\n-   Command line arguments are now evaluated with `eval` instead of `JSON.parse`.\n\u003c!-- @TODO add an example here --\u003e\n-   `-v` and `--version` are reserved for printing the version.\n-   `@private` JSDoc tag is now replaced with `@cliPrivate`.\n-   The `@CLI` JSDoc tag can now get a value as a custom name for the command.\n\n**non breaking changes**\n\n-   `json5` node module is used for parsing `package.json` and `tsconfig.json`. That means (among others) no more headaches with trailing commas.\n-   You can now add any type you want for command options.\n-   The default JSDoc tag value is no longer validated that it is the same type as the argument type.\n\n**other**\n\n-   `README.md` has been improved and extra sections like changelog and contributing have been added. You can read the example section code in the `README.md` now.\n\n### 1.0.0\n\n-   Published the package to npm.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flillallol%2Ffn-to-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flillallol%2Ffn-to-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flillallol%2Ffn-to-cli/lists"}