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

Config #422

Merged
merged 12 commits into from
Nov 26, 2024
Merged

Config #422

merged 12 commits into from
Nov 26, 2024

Conversation

echo-bravo-yahoo
Copy link
Contributor

@echo-bravo-yahoo echo-bravo-yahoo commented Nov 22, 2024

brief

this change implements the --config flag, adds config parsing to the CLI, and adds env var parsing to the CLI.

it will accept any flags that any commands or subcommands define, but attempts to use a command with an incompatible flag will fail because of strict mode. because of this, it's wisest to only use globally defined flags for the default profile.

how does config actually work?

given a config file with this content (note that JSON is also valid):

default:
  secret: very-secret
  color: true

ci:
  secret: even-more-secret
  color: false

and this env var:

FAUNA_CONFIG=/path/to/config.yaml
FAUNA_SECRET=not-so-secret

running fauna eval --query "Database.all()" would:

  1. use the env var to locate and read the config file
  2. overlay the config file's default profile (since none was specified in flags or env vars) with the env vars and flags, following this precedence: flags > env vars > config entries
  3. run the command with the resulting argv. in this case, it would be equivalent to: fauna eval --secret "not-so-secret" --color --query "Database.all()"

@echo-bravo-yahoo echo-bravo-yahoo marked this pull request as ready for review November 25, 2024 22:20
@echo-bravo-yahoo echo-bravo-yahoo requested a review from a team as a code owner November 25, 2024 22:20
@echo-bravo-yahoo echo-bravo-yahoo merged commit e37507e into v3 Nov 26, 2024
4 checks passed
@echo-bravo-yahoo echo-bravo-yahoo deleted the config branch November 26, 2024 17:15
@@ -255,6 +255,7 @@ function buildEvalCommand(yargs) {
query: {
type: "string",
description: "the query to run",
required: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this right? I thought a user could specify --query or --file, and they're mutually exclusive.

@cleve-fauna cleve-fauna mentioned this pull request Dec 5, 2024
This was referenced Dec 6, 2024
@cleve-fauna cleve-fauna mentioned this pull request Dec 13, 2024
@wildemat wildemat mentioned this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants