From 8ba09c44181cc05fe6408632d3e896a03d2c4b44 Mon Sep 17 00:00:00 2001 From: Ashton Eby Date: Fri, 13 Dec 2024 14:52:41 -0800 Subject: [PATCH 1/2] improve help text for --version, local flags --- src/cli.mjs | 17 ++++++++++++++++- src/commands/local.mjs | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/cli.mjs b/src/cli.mjs index a4d70b4a..81f682f2 100644 --- a/src/cli.mjs +++ b/src/cli.mjs @@ -1,5 +1,9 @@ // @ts-check +import fs from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + import chalk from "chalk"; import yargs from "yargs"; @@ -26,6 +30,9 @@ export let container; /** @type {import('yargs').Argv} */ export let builtYargs; +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + /** * @param {string|string[]} _argvInput - The command string provided by the user or test. Parsed by yargs into an argv object. * @param {cliContainer} _container - A built and ready for use awilix container with registered injectables. @@ -169,7 +176,15 @@ function buildYargs(argvInput) { .alias("help", "h") .fail(false) .exitProcess(false) - .version() + .version( + "version", + "Show the fauna CLI version.", + JSON.parse( + fs.readFileSync(path.join(__dirname, "../package.json"), { + encoding: "utf8", + }), + ).version, + ) .completion( "completion", "Output bash/zsh script to enable shell completions. See command output for installation instructions.", diff --git a/src/commands/local.mjs b/src/commands/local.mjs index ec1b7ef3..edd2e543 100644 --- a/src/commands/local.mjs +++ b/src/commands/local.mjs @@ -58,7 +58,7 @@ function buildLocalCommand(yargs) { default: 100, }, name: { - describe: "The name to give the container", + describe: "The name to give the container.", type: "string", default: "faunadb", }, @@ -86,7 +86,7 @@ function buildLocalCommand(yargs) { export default { command: "local", - describe: "Start a local Fauna container", + describe: "Start a local Fauna container.", builder: buildLocalCommand, handler: startLocal, }; From b613fc77dfa42c15486e9a7bed3ddf4d18345266 Mon Sep 17 00:00:00 2001 From: "E. Cooper" Date: Mon, 16 Dec 2024 11:07:16 -0800 Subject: [PATCH 2/2] Fix bad conflict resolution --- src/cli.mjs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/cli.mjs b/src/cli.mjs index f1fd1003..1a160b72 100644 --- a/src/cli.mjs +++ b/src/cli.mjs @@ -123,9 +123,6 @@ function buildYargs(argvInput) { .completion( "completion", "Output bash/zsh script to enable shell completions. See command output for installation instructions.", - ) - .completion( - "completion", async function (currentWord, argv, defaultCompletions, done) { // this is pretty hard to debug - if you need to, run // `fauna --get-yargs-completions ` @@ -229,8 +226,5 @@ function buildYargs(argvInput) { encoding: "utf8", }), ).version, - ) - .completion( - "completion", - "Output bash/zsh script to enable shell completions. See command output for installation instructions.", - ); \ No newline at end of file + ); +}