index.js (1137B)
1 const commander = require('commander'); 2 3 // @ts-check 4 5 exports = module.exports = {}; 6 7 // Return a different global program than commander, 8 // and don't also return it as default export. 9 exports.program = new commander.Command(); 10 11 /** 12 * Expose classes. The FooT versions are just types, so return Commander original implementations! 13 */ 14 15 exports.Argument = commander.Argument; 16 exports.Command = commander.Command; 17 exports.CommanderError = commander.CommanderError; 18 exports.Help = commander.Help; 19 exports.InvalidArgumentError = commander.InvalidArgumentError; 20 exports.InvalidOptionArgumentError = commander.InvalidArgumentError; // Deprecated 21 exports.Option = commander.Option; 22 23 // In Commander, the create routines end up being aliases for the matching 24 // methods on the global program due to the (deprecated) legacy default export. 25 // Here we roll our own, the way Commander might in future. 26 exports.createCommand = (name) => new commander.Command(name); 27 exports.createOption = (flags, description) => new commander.Option(flags, description); 28 exports.createArgument = (name, description) => new commander.Argument(name, description);