{"library":"shell","title":"Shell CLI Argument Parser and Router","description":"Shell.js is a declarative command-line argument parser and stringifier for Node.js, currently at version 0.12.0, with its latest update published approximately a year ago. It's designed to simplify the creation of complex CLI applications by providing a structured way to define options, commands, and their associated routing logic. Key features include automatic argument discovery, support for multi-level commands (e.g., `git pull origin main`), built-in type conversion for arguments (string, boolean, integer, array), and auto-generated help messages. It differentiates itself through a declarative API that integrates parsing, stringifying, and routing into a single configuration object, making CLI development more intuitive than some imperative alternatives. The package is actively maintained and currently requires Node.js version 20 or later.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install shell"],"cli":null},"imports":["import { shell } from 'shell';","const cli = shell({\n  name: 'my-app',\n  description: 'My CLI application',\n  options: { version: { shortcut: 'v', description: 'Show version' } },\n  commands: { start: { description: 'Start the application' } }\n});\ncli.route();","const { shell } = require('shell');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { shell } from 'shell';\n\nconst myCli = shell({\n  name: 'complex-app',\n  description: 'A robust command-line application demonstrating parsing and routing.',\n  options: {\n    verbose: { shortcut: 'v', description: 'Enable verbose logging', type: 'boolean' },\n    config: { shortcut: 'c', description: 'Path to configuration file', type: 'string', default: './config.json' }\n  },\n  commands: {\n    start: {\n      description: 'Start a service or process.',\n      options: {\n        port: { shortcut: 'p', description: 'Port to listen on', type: 'integer', default: 3000 }\n      },\n      main: async ({ options }) => {\n        console.log(`Starting service on port ${options.port} with config: ${options.config} (verbose: ${options.verbose})`);\n        // Simulate async operation\n        await new Promise(resolve => setTimeout(resolve, 1000));\n        console.log('Service started successfully.');\n      }\n    },\n    stop: {\n      description: 'Stop a running service.',\n      main: () => {\n        console.log('Stopping service...');\n        console.log('Service stopped.');\n      }\n    }\n  }\n});\n\nmyCli.route().catch(err => {\n  console.error('CLI Error:', err.message);\n  process.exit(1);\n});\n\n// To run this: save as `cli.js`, add `\"type\": \"module\"` to package.json.\n// Then run: `node cli.js start -p 8080 --verbose` or `node cli.js stop -c my-dev-config.json`","lang":"javascript","description":"This quickstart defines a CLI with global options, subcommands, and subcommand-specific options, demonstrating the declarative API for parsing and routing with `shell.js`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}