mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 06:28:33 +00:00
feat: bru cli init
This commit is contained in:
18
packages/bruno-cli/src/commands/run.js
Normal file
18
packages/bruno-cli/src/commands/run.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const chalk = require('chalk');
|
||||
|
||||
const command = 'run';
|
||||
const desc = 'Run request';
|
||||
|
||||
const builder = async (yargs) => {
|
||||
try {
|
||||
console.log(chalk.yellow('Running request'));
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
command,
|
||||
desc,
|
||||
builder
|
||||
};
|
||||
9
packages/bruno-cli/src/constants.js
Normal file
9
packages/bruno-cli/src/constants.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const { version } = require('../package.json');
|
||||
|
||||
const CLI_EPILOGUE = `Documentation: https://docs.usebruno.com (v${version})`;
|
||||
const CLI_VERSION = version;
|
||||
|
||||
module.exports = {
|
||||
CLI_EPILOGUE,
|
||||
CLI_VERSION
|
||||
};
|
||||
@@ -1 +1,31 @@
|
||||
console.log("This is bruno cli");
|
||||
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}`));
|
||||
}
|
||||
|
||||
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]')
|
||||
.demandCommand(1, "Woof !! Let's play with some apis !!")
|
||||
.help('h')
|
||||
.alias('h', 'help');
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
run
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user