forked from extern/bruno
feat: bru cli init
This commit is contained in:
parent
3e563ea126
commit
c524f40ab2
@ -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
3
packages/bruno-cli/bin/bru.js
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('../src').run();
|
@ -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"
|
||||
|
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
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user