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

lang: Improve cli input handling for files/directories and metadata.yaml #683

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Nov 23, 2021

  1. 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>
    frebib committed Nov 23, 2021
    Configuration menu
    Copy the full SHA
    4cb287a View commit details
    Browse the repository at this point in the history
  2. 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:
    
        $ 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>
    frebib committed Nov 23, 2021
    Configuration menu
    Copy the full SHA
    5d32044 View commit details
    Browse the repository at this point in the history