lang: Improve cli input handling for files/directories and metadata.yaml
#683
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