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

Configuration errors improvements: exit on CLI errors, include line number and filepath #2454

Merged
merged 8 commits into from
Oct 18, 2024

Conversation

mitchellh
Copy link
Contributor

@mitchellh mitchellh commented Oct 18, 2024

Fixes #1063
Fixes #2437
Supersedes #2033 (Thanks @wpaulino for your initial work, I did take some inspiration)

Configuration errors are now known as "diagnostics" (to give us room to fit more than errors in the future since it's a more general reporting system). Diagnostics contain a location which can be used to generate error messages with context such as line numbers and file paths.

The GTK and GLFW apprts now exit when an invalid CLI argument is given (#2437). macOS always behaved this way.

Rather than storing a list of errors we now store a list of
"diagnostics." Each diagnostic has a richer set of structured
information, including a message, a key, the location where it occurred.

This lets us show more detailed messages, more human friendly messages, and
also let's us filter by key or location. We don't take advantage of
all of this capability in this initial commit, but we do use every field
for something.
It was unused and doesn't match our diagnostic API.
@mitchellh mitchellh merged commit 98a7573 into main Oct 18, 2024
34 checks passed
@mitchellh mitchellh deleted the diags branch October 18, 2024 15:35
// If we're quitting, then we set the quit flag and stop
// draining the mailbox immediately. This lets us defer
// mailbox processing to the next tick so that the apprt
// can try to quick as quickly as possible.
Copy link
Member

Choose a reason for hiding this comment

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

s/quick/quit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Snuck this into #2455

mitchellh added a commit that referenced this pull request Oct 18, 2024
This fixes a regression from #2454. In that PR, we added an error when
positional arguments are detected. I believe that's correct, but we
were silently relying on the previous behavior in the CLI commands.

This commit changes the CLI commands to use a new argsIterator function
that creates an iterator that skips the first argument (argv0). This is
the same behavior that the config parsing does and now uses this shared
logic.

This also makes it so the argsIterator ignores actions (`+things`)
and we document that we expect those to be handled earlier.
mitchellh added a commit that referenced this pull request Oct 18, 2024
This fixes a regression from #2454. In that PR, we added an error when
positional arguments are detected. I believe that's correct, but we
were silently relying on the previous behavior in the CLI commands.

This commit changes the CLI commands to use a new argsIterator function
that creates an iterator that skips the first argument (argv0). This is
the same behavior that the config parsing does and now uses this shared
logic.

This also makes it so the argsIterator ignores actions (`+things`)
and we document that we expect those to be handled earlier.
mitchellh added a commit that referenced this pull request Oct 18, 2024
This fixes a regression from #2454. In that PR, we added an error when
positional arguments are detected. I believe that's correct, but we
were silently relying on the previous behavior in the CLI commands.

This commit changes the CLI commands to use a new argsIterator function
that creates an iterator that skips the first argument (argv0). This is
the same behavior that the config parsing does and now uses this shared
logic.

This also makes it so the argsIterator ignores actions (`+things`)
and we document that we expect those to be handled earlier.
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.

CLI should error on invalid flags Show which line an error occurs when loading the configuration
2 participants