From 404a516fef912e00108892edb3c7dc92c6d9b3cd Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Mon, 6 Feb 2023 02:57:59 +0530 Subject: [PATCH] chore: bruno cli accept request filename --- packages/bruno-cli/package.json | 4 ++- packages/bruno-cli/src/commands/run.js | 39 +++++++++++++++++++++----- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/packages/bruno-cli/package.json b/packages/bruno-cli/package.json index 60d53ca7..e9cdb48f 100644 --- a/packages/bruno-cli/package.json +++ b/packages/bruno-cli/package.json @@ -10,7 +10,9 @@ "package.json" ], "dependencies": { - "chalk": "^5.2.0", + "@usebruno/js": "0.1.0", + "@usebruno/lang": "0.1.0", + "chalk": "^3.0.0", "inquirer": "^9.1.4", "yargs": "^17.6.2" } diff --git a/packages/bruno-cli/src/commands/run.js b/packages/bruno-cli/src/commands/run.js index e3c8c1ab..4e63f204 100644 --- a/packages/bruno-cli/src/commands/run.js +++ b/packages/bruno-cli/src/commands/run.js @@ -1,18 +1,43 @@ const chalk = require('chalk'); +const { + CLI_EPILOGUE, +} = require('../constants'); const command = 'run'; -const desc = 'Run request'; +const desc = 'Run a request'; + +const cmdArgs = { + filename: { + desc: 'Run a request', + type: 'string', + } +}; + const builder = async (yargs) => { - try { - console.log(chalk.yellow('Running request')); - } catch (err) { - console.error(err); - } + yargs.options(cmdArgs).epilogue(CLI_EPILOGUE).help(); + yargs.example('$0 filename', 'Run a request'); }; +const handler = async function (argv) { + try { + if (!argv.filename) { + console.log(chalk.cyan('Please specify a filename')); + console.log(`Example: ${argv.$0} run request.bru`); + + return; + } + console.log("here"); + } catch (err) { + console.error(err); + } +}; + + module.exports = { command, desc, - builder + builder, + cmdArgs, + handler };