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

Validate command #279

Merged
merged 4 commits into from
Oct 28, 2019
Merged

Validate command #279

merged 4 commits into from
Oct 28, 2019

Conversation

squaremo
Copy link
Member

@squaremo squaremo commented Oct 16, 2019

$ jk help validate
Validate configuration files

Usage:
  jk validate <file>... [flags]

Examples:

  validating YAML files using a module's default export
    jk validate -m '@example.com/validate' *.{yaml,yml}

  validating YAMLs and JSONs using a local script's default export
    jk validate ./valid.js *.{yaml,yml,json}

  validating a specific file with an inline validation function
    jk validate -c 'v => v.name === "correctName"' config.json


Flags:
  -d, --emit-dependencies         emit script dependencies
  -c, --exec                      treat first argument as specifying literal JavaScript to execute
  -h, --help                      help for validate
  -m, --module                    treat first argument as specifying a module to load
  -o, --output-directory string   where to output generated files
  -p, --parameter name=value      set input parameters
  -f, --parameters filename       load parameters from a JSON or YAML file
  -v, --verbose                   verbose output

Fixes: #235

@squaremo
Copy link
Member Author

Stretch goals (for the record; not intending them to be done in the PR):

  • global validation -- validation that acts on the whole set of objects (how to provide an argument for it?)
  • -r treat the file arguments as directories into which to descend

-r makes most sense if there's global validation -- otherwise, you could just get the list of files with find | xargs.

This uses the same pattern as `generate` and `transform`, of
interpolating bits into a template which calls a "main" JavaScript
procedure, to implement `validate`.
@squaremo
Copy link
Member Author

(rebased and moved support JS to cmd/ as with #284)

@squaremo
Copy link
Member Author

@dlespiau How do you feel about this new subcommand?

Copy link
Member

@dlespiau dlespiau left a comment

Choose a reason for hiding this comment

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

Looks useful to me! I like that we didn't go with a recursive mode, leaving the choice of which files to select to the command line (which could be a find + xargs).

@squaremo squaremo merged commit 259cc37 into master Oct 28, 2019
@squaremo squaremo deleted the validate-command branch October 28, 2019 11:51
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.

jk validate
2 participants