{"library":"make-cli","title":"make-cli: Declarative CLI Framework","description":"make-cli is a declarative framework for building command-line interfaces in Node.js, distinguished by its streamlined approach that centers around a single configuration object and a single function call. It aims to simplify CLI development by abstracting away much of the boilerplate often associated with argument parsing and command definition. The current stable version is 6.0.2, with major versions typically aligned with Node.js LTS releases (e.g., v5 required Node.js >= 20, v6 requires Node.js >= 22). Patch and minor releases occur regularly to address bugs and introduce minor enhancements. Built on top of Commander.js, make-cli leverages its robust parsing capabilities while offering a more functional and declarative API. This design makes it particularly appealing for developers who prefer a concise and config-driven style for their CLI tools, differentiating it from more imperative or class-based alternatives by providing a highly approachable entry point for creating complex command structures.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install make-cli"],"cli":{"name":"make-cli","version":null}},"imports":["import makeCli from 'make-cli';","import type { MakeCliOptions } from 'make-cli';","import makeCli from 'make-cli';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"#!/usr/bin/env node\n\nimport makeCli from 'make-cli';\nimport { resolve } from 'path';\n\ninterface MyCliOptions {\n  yes?: boolean;\n  value: string;\n  force?: boolean;\n}\n\nmakeCli<MyCliOptions>({\n  version: '0.1.0',\n  name: 'my-cli',\n  usage: 'A simple demonstration CLI for make-cli',\n  arguments: '<remote> [extra]',\n  options: [\n    {\n      name: '-y, --yes',\n      description: 'Skip interactive prompts and confirm actions',\n      default: false\n    },\n    {\n      name: '--value <value>',\n      description: 'Specifies an important configuration value',\n      defaultValue: 'default_foo',\n      choices: ['default_foo', 'bar', 'baz']\n    }\n  ],\n  action: async (remote: string, extra: string | undefined, options: MyCliOptions) => {\n    console.log(`Executing action for remote: ${remote || '[no remote]'}`);\n    console.log(`Extra argument: ${extra || '[no extra]'}`);\n    console.log(`Options: Yes=${options.yes}, Value=${options.value}`);\n    \n    if (options.yes) {\n      console.log('Skipping interactive confirmation due to --yes flag.');\n    } else {\n      console.log('Performing interactive confirmation...');\n    }\n    console.log(`Resolved path example: ${resolve('.')}`);\n    await new Promise(resolve => setTimeout(resolve, 100)); // Simulate async work\n    console.log('Main action completed.');\n  },\n  commands: [\n    {\n      name: 'push',\n      description: 'Pushes changes to the remote repository',\n      arguments: '<remote>',\n      options: [\n        {\n          name: '-f, --force',\n          description: 'Force push',\n          default: false\n        }\n      ],\n      handler: async (remote: string, { force }: { force: boolean }) => {\n        console.log(`Executing 'push' command to ${remote} with force=${force}`);\n        await new Promise(resolve => setTimeout(resolve, 50));\n        console.log('Push command executed.');\n      }\n    }\n  ]\n});","lang":"typescript","description":"This example demonstrates defining a CLI with global arguments and options, an main action handler, and a subcommand. It includes TypeScript types, async operations, and option validation with 'choices'.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}