{"id":23700997,"url":"https://github.com/lennetech/cli-plugin-helper","last_synced_at":"2026-01-29T09:30:14.851Z","repository":{"id":35108372,"uuid":"206069617","full_name":"lenneTech/cli-plugin-helper","owner":"lenneTech","description":"A Helper for CLI Projects","archived":false,"fork":false,"pushed_at":"2023-01-08T16:01:28.000Z","size":746,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-30T17:51:27.793Z","etag":null,"topics":[],"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/lenneTech.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":"2019-09-03T12:16:15.000Z","updated_at":"2022-04-22T06:46:07.000Z","dependencies_parsed_at":"2023-01-15T13:59:13.128Z","dependency_job_id":null,"html_url":"https://github.com/lenneTech/cli-plugin-helper","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenneTech%2Fcli-plugin-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenneTech%2Fcli-plugin-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenneTech%2Fcli-plugin-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenneTech%2Fcli-plugin-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lenneTech","download_url":"https://codeload.github.com/lenneTech/cli-plugin-helper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239776509,"owners_count":19695118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-12-30T09:31:24.610Z","updated_at":"2026-01-29T09:30:13.221Z","avatar_url":"https://github.com/lenneTech.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CLI Plugin: Helper\n\nThe CLI-Plugin: Helper integrates the helper extension for [Gluegun](https://infinitered.github.io/gluegun) CLIs.\n\nIt contains\n\n- `showMenu`: A menu maker for your commands\n- `getConfig`: Extends the handling of the configuration, also for ~/.\u003cCLI_BRAND\u003e\n- `getDir`: Extension of path.join that can handle homedir (~) and automatic OS-specific separator conversion\n- `getInput`: Checks inputs (e.g. from parameters) and asks if they are not set\n- `msToMinutesAndSeconds`: Converts milliseconds to minutes:seconds string\n- `readFile`: Read a file and get the (JSON) data\n- `trim`: Extension of the string.trim that also replaces line breaks\n- `updateCli`: Helps you to keep your CLI up to date\n- ...\n\nMenu in action:\n\n![Gluegun Menu Demo](assets/demo.gif)\n\n## Integration\n\nIt can be easily integrated into your CLI:\n\n### 1. Install extension:\n\n```bash\n$ npm install @lenne.tech/cli-plugin-helper\n```\n\n### 2. Integrate extension as plugin:\n\n`src/cli.ts`:\n\n```typescript\n// ...\nconst cli = build()\n  // ...\n  .plugin(__dirname + '/../node_modules/@lenne.tech/cli-plugin-helper/dist', {\n    commandFilePattern: '*.js',\n    extensionFilePattern: '*.js'\n  })\n  // ...\n  .create();\n// ...\n```\n\n### 3. Extend interface:\n\n`src/interfaces/extended-gluegun-toolbox.ts`:\n\n```typescript\nimport { Helper } from '@lenne.tech/cli-plugin-helper';\n// ...\n\n/**\n * Extended GluegunToolbox\n */\nexport interface ExtendedGluegunToolbox extends GluegunToolbox {\n  helper: Helper;\n  // ...\n}\n```\n\n### 4. Prepare main commands:\n\n`src/commands/YOUR_COMMAND/YOUR_COMMAND.ts`:\n\n```typescript\nimport { IHelperExtendedGluegunToolbox } from '@lenne.tech/cli-plugin-helper';\n\n/**\n * YOUR_COMMAND menu\n */\nmodule.exports = {\n  name: 'YOUR_COMMAND',\n  alias: ['YOUR_COMMAND_ALIAS'],\n  description: 'YOUR_DESCRIPTION',\n  hidden: true,\n  run: async (toolbox: IHelperExtendedGluegunToolbox) =\u003e {\n    await toolbox.helper.showMenu('(PARANT_COMMANDS) YOUR_COMMAND');\n  }\n};\n```\n\n## Parameters of `showMenu`\n\n1. parentCommands?: string  \n   command name OR parent names + command name\n\n2. options?: object\n\n   - level: number =\u003e Level of the current section (0 = main section)\n   - headline: string =\u003e Headline for the current section\n\nNote: If the options in the main menu are to be used, for example to define the headline,\n`null` or an empty string `''` must be passed as the first parameter:  \n`showMenu(null, {headline: 'Main menu'})`\n\n## Example\n\nExample file structure:\n\n```\nsrc/commands/\n    section1/\n        subsection1/\n            subsection1.ts\n            yyy1.ts\n            yyy2.ts\n        section1.ts\n        xxx1.ts\n        xxx2.ts\n    section2/\n        section2.ts\n        zzz1.ts\n        zzz2.ts\n    brand.ts\n```\n\n`src/commands/brand.ts`:\n\n```typescript\nimport { IHelperExtendedGluegunToolbox } from '@lenne.tech/cli-plugin-helper';\n\n/**\n * Main menu\n */\nmodule.exports = {\n  name: 'brand',\n  description: 'Welcome to brand CLI',\n  hidden: true,\n  run: async (toolbox: IHelperExtendedGluegunToolbox) =\u003e {\n    await toolbox.helper.showMenu();\n  }\n};\n```\n\n`src/commands/section1/section1.ts`:\n\n```typescript\nimport { IHelperExtendedGluegunToolbox } from '@lenne.tech/cli-plugin-helper';\n\n/**\n * Section1 menu\n */\nmodule.exports = {\n  name: 'section1',\n  alias: ['s1'],\n  description: 'Description for section1',\n  hidden: true,\n  run: async (toolbox: IHelperExtendedGluegunToolbox) =\u003e {\n    await toolbox.helper.showMenu('section1');\n  }\n};\n```\n\n`src/commands/section1/subsection1/subsection1.ts`:\n\n```typescript\nimport { IHelperExtendedGluegunToolbox } from '@lenne.tech/cli-plugin-helper';\n\n/**\n * Subsection1 menu\n */\nmodule.exports = {\n  name: 'subsection1',\n  alias: ['sub1'],\n  description: 'Description for subsection1',\n  hidden: true,\n  run: async (toolbox: IHelperExtendedGluegunToolbox) =\u003e {\n    await toolbox.helper.showMenu('section1 subsection1', { headline: 'Subsection1 commands' });\n  }\n};\n```\n\n## Thanks\n\nMany thanks to the developers of [Glugun](https://infinitered.github.io/gluegun)\nand all the developers whose packages are used here.\n\n## License\n\nMIT - see LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flennetech%2Fcli-plugin-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flennetech%2Fcli-plugin-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flennetech%2Fcli-plugin-helper/lists"}