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

group options #463

Merged
merged 2 commits into from
Dec 4, 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
22 changes: 17 additions & 5 deletions src/cli.mjs
Copy link
Contributor

@ptpaterson ptpaterson Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about something like "Authentication/Authorization" instead of "API"? definitely more verbose... "AuthN/Z"? "Auth"?

Copy link
Collaborator Author

@echo-bravo-yahoo echo-bravo-yahoo Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's what's in the group now:
image

i feel like database and url are only tenuously auth? but it is a clearer expression of what they do than "API". except for those 2? bleh.

Original file line number Diff line number Diff line change
Expand Up @@ -158,46 +158,58 @@ function buildYargs(argvInput) {
type: "boolean",
// https://github.com/chalk/chalk?tab=readme-ov-file#chalklevel
default: chalk.level > 0,
group: "Output:",
},
config: {
type: "string",
description: "Path to a CLI config file to use. Use `--profile` to select a profile from the file.",
description:
"Path to a CLI config file to use. Use `--profile` to select a profile from the file.",
default: ".",
group: "Config:",
},
profile: {
alias: "p",
type: "string",
description:
"Profile from the CLI config file to use. Each profile specifies a set of CLI settings.",
default: "default",
group: "Config:",
},
user: {
alias: "u",
type: "string",
description: "User account used to run the command. Register a user account in the CLI using `fauna login`.",
description:
"User account used to run the command. Register a user account in the CLI using `fauna login`.",
default: "default",
group: "API:",
},
json: {
type: "boolean",
description: "Output the results as JSON.",
default: false,
group: "Output:",
},
quiet: {
type: "boolean",
description: "Only output the results of the command. Useful for scripts, CI/CD, and automation workflows.",
description:
"Only output the results of the command. Useful for scripts, CI/CD, and automation workflows.",
default: false,
group: "Output:",
},
verboseComponent: {
description:
"Components to emit diagnostic logs for. Takes precedence over the `--verbosity` flag. Pass components as a comma-separate list, such as `--verboseComponent fetch, error`, or as separate flags, such as `--verboseComponent fetch --verboseComponent error`.",
"Components to emit diagnostic logs for. Takes precedence over the `--verbosity` flag. Pass components as a space-separated list, such as `--verboseComponent fetch error`, or as separate flags, such as `--verboseComponent fetch --verboseComponent error`.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

type: "array",
default: [],
choices: ["fetch", "error", "config", "argv", "creds"],
group: "Debug:",
},
verbosity: {
description: "Maximum verbosity level for log messages. Accepts 1 (fatal) to 5 (debug). Lower values represent more critical logs.",
description:
"Maximum verbosity level for log messages. Accepts 1 (fatal) to 5 (debug). Lower values represent more critical logs.",
type: "number",
default: 0,
group: "Debug:",
},
})
.wrap(yargsInstance.terminalWidth())
Expand Down
33 changes: 21 additions & 12 deletions src/lib/command-helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,36 @@ const COMMON_QUERY_OPTIONS = {
describe:
'Use a local Fauna container. If not otherwise specified, sets `--url` to http://localhost:8443 and `--secret` to "secret".',
default: false,
group: "API:",
},
url: {
type: "string",
description:
"URL for Fauna Core HTTP API requests made by the command. Defaults to https://db.fauna.com.",
group: "API:",
},
secret: {
type: "string",
description:
"Authentication secret for Fauna Core HTTP API requests made by the command. Mutually exclusive with `--database` and `--role`.",
required: false,
group: "API:",
},
database: {
alias: "d",
type: "string",
description:
"Path, including Region Group identifier and hierarchy, for the database to run the command in. Mutually exclusive with `--secret`.",
group: "API:",
},
role: {
alias: "r",
type: "string",
description:
"Role used to run the command. Mutually exclusive with `--secret`.",
group: "API:",
},
// hidden
accountUrl: {
type: "string",
description: "the Fauna account URL to query",
Expand All @@ -37,18 +55,6 @@ const COMMON_QUERY_OPTIONS = {
required: false,
hidden: true,
},
database: {
alias: "d",
type: "string",
description:
"Path, including Region Group identifier and hierarchy, for the database to run the command in. Mutually exclusive with `--secret`.",
},
role: {
alias: "r",
type: "string",
description:
"Role used to run the command. Mutually exclusive with `--secret`.",
},
};

/**
Expand Down Expand Up @@ -147,19 +153,22 @@ const COMMON_CONFIGURABLE_QUERY_OPTIONS = {
alias: "v",
default: "10",
choices: ["4", "10"],
group: "API:",
},
// v10 specific options
typecheck: {
type: "boolean",
description:
"Enable typechecking. Defaults to the typechecking setting of the database.",
default: undefined,
group: "API:",
},
timeout: {
type: "number",
description:
"Maximum runtime, in milliseconds, for Fauna Core HTTP API requests made by the command.",
default: 5000,
group: "API:",
},
};

Expand Down
Loading