lang: Improve cli input handling for files/directories and metadata.yaml#683
Open
frebib wants to merge 2 commits into
Open
lang: Improve cli input handling for files/directories and metadata.yaml#683frebib wants to merge 2 commits into
metadata.yaml#683frebib wants to merge 2 commits into
Conversation
Handle the case of passing 'metadata.yaml' as an input source to the input selector and parse the relative path to the file the same way as it would be handled if it were a relative path with a directory component, or an absolute path. Signed-off-by: Joe Groocock <me@frebib.net>
d322bd5 to
5c1eaf5
Compare
Differentiate between ENOENT and other errors returned by stat(2) to
prevent confusing parse errors when the path provided is a directory
path. ENOENT is silently ignored as file or directory absence can be
expected depending on the specified input from the user.
Handle directory paths without trailing slashes from the user input on
the command line, correctly disambiguating directories from files with
the stat(2) result.
This fixes the rather confusing situation where mgmt would report a
parse error on the input string of the directory name as if it didn't
exist, but instead stat(2) just returned another error such as EACCES or
otherwise. Now correctly report errors that aren't ENOENT.
Before:
$ mgmt run lang files
2020-11-24 20:48:33.350321 I | cli: lang: input from code source: files
2020-11-24 20:48:33.350389 I | cli: lang: lexing/parsing...
2020-11-24 20:48:33.350528 I | run: error: cli parse error: could not generate AST: parser: `syntax error: unexpected $end` @1:1
After:
$ mgmt run lang files
2020-11-24 20:53:35.500436 I | run: error: cli parse error: could not activate an input parser: stat /home/frebib/mgmt/files/metadata.yaml: permission denied
Signed-off-by: Joe Groocock <me@frebib.net>
5c1eaf5 to
5d32044
Compare
2319f4f to
04f5ba6
Compare
fe2313c to
271a94e
Compare
b8072b2 to
380004b
Compare
37fdda9 to
5f4ae05
Compare
3221a93 to
4ad2b9a
Compare
b7ee313 to
cb70565
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
lang: correctly handle stat(2) errors on directories/files
Differentiate between ENOENT and other errors returned by stat(2) to
prevent confusing parse errors when the path provided is a directory
path. ENOENT is silently ignored as file or directory absence can be
expected depending on the specified input from the user.
Handle directory paths without trailing slashes from the user input on
the command line, correctly disambiguating directories from files with
the stat(2) result.
This fixes the rather confusing situation where mgmt would report a
parse error on the input string of the directory name as if it didn't
exist, but instead stat(2) just returned another error such as EACCES or
otherwise. Now correctly report errors that aren't ENOENT.
Before:
After:
Signed-off-by: Joe Groocock me@frebib.net
lang: allow 'mgmt lang run metadata.yaml'
Handle the case of passing 'metadata.yaml' as an input source to the
input selector and parse the relative path to the file the same way as
it would be handled if it were a relative path with a directory
component, or an absolute path.
Signed-off-by: Joe Groocock me@frebib.net