UNPKG

magicli

Version:

Automagically generates command-line interfaces (CLI) for any module. Expected options and help sections are created automatically based on parameters names, with support to async. It can be installed globally, in order to *execute* any module, or .js fil

21 lines (16 loc) 554 B
#!/usr/bin/env node 'use strict' const { name, description, version } = require('../package.json'); const path = require('path'); const fs = require('fs'); if (!process.argv[2]) { console.error('The first argument must be the path to a module or to a .js file'); return; } const modulePath = path.resolve(process.argv[2]); if (!fs.existsSync(modulePath)) { console.error('The first argument must be a valid path to a module or to a .js file'); return; } process.argv = [process.argv[0], ...process.argv.slice(2)]; require('../')({ modulePath });