bruno/packages/bruno-cli/src/index.js

31 lines
719 B
JavaScript
Raw Normal View History

2023-02-05 21:57:22 +01:00
const yargs = require('yargs');
const chalk = require('chalk');
const { CLI_EPILOGUE, CLI_VERSION } = require('./constants');
const printBanner = () => {
console.log(chalk.yellow(`Bru CLI ${CLI_VERSION}`));
};
2023-02-05 21:57:22 +01:00
const run = async () => {
const argLength = process.argv.length;
const commandsToPrintBanner = ['--help', '-h'];
if (argLength <= 2 || process.argv.find((arg) => commandsToPrintBanner.includes(arg))) {
printBanner();
}
const { argv } = yargs
.strict()
.commandDir('commands')
.epilogue(CLI_EPILOGUE)
.usage('Usage: $0 <command> [options]')
2024-06-21 08:02:45 +02:00
.demandCommand(1, "Woof!! Let's play with some APIs!!")
2023-02-05 21:57:22 +01:00
.help('h')
.alias('h', 'help');
};
module.exports = {
run
};