feat: bru cli init

This commit is contained in:
Anoop M D 2023-02-06 02:27:22 +05:30 committed by Anoop M D
parent 3e563ea126
commit c524f40ab2
6 changed files with 66 additions and 2 deletions

View File

@ -4,6 +4,7 @@
"workspaces": [
"packages/bruno-app",
"packages/bruno-electron",
"packages/bruno-cli",
"packages/bruno-tauri",
"packages/bruno-schema",
"packages/bruno-js",

3
packages/bruno-cli/bin/bru.js Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env node
require('../src').run();

View File

@ -1,7 +1,10 @@
{
"name": "usebruno",
"name": "@usebruno/cli",
"version": "0.1.0",
"main": "src/index.js",
"bin": {
"bru": "./bin/bru.js"
},
"files": [
"src",
"package.json"

View 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
};

View 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
};

View File

@ -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
};