Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve help text for --version, local flags #527

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/cli.mjs
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -27,6 +31,9 @@
/** @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.
Expand Down Expand Up @@ -116,9 +123,6 @@
.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 <command> <flag> <string to match>`
Expand All @@ -137,7 +141,7 @@
.filter((key) => previousWord === key)
.pop();

// TODO: this doesn't handle aliasing, and it needs to

Check warning on line 144 in src/cli.mjs

View workflow job for this annotation

GitHub Actions / lint

Unexpected 'todo' comment: 'TODO: this doesn't handle aliasing, and...'
if (
currentWord === "--profile" ||
currentWordFlag === "profile" ||
Expand Down Expand Up @@ -214,5 +218,13 @@
.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,
);
}
4 changes: 2 additions & 2 deletions src/commands/local.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,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",
},
Expand Down Expand Up @@ -183,7 +183,7 @@ function buildLocalCommand(yargs) {

export default {
command: "local",
describe: "Start a local Fauna container",
describe: "Start a local Fauna container.",
builder: buildLocalCommand,
handler: startLocal,
};
Loading