Skip to content

Adding a --validate CLI option#84

Closed
AVGP wants to merge 1 commit into
json5:masterfrom
AVGP:cli-validate
Closed

Adding a --validate CLI option#84
AVGP wants to merge 1 commit into
json5:masterfrom
AVGP:cli-validate

Conversation

@AVGP

@AVGP AVGP commented Dec 23, 2014

Copy link
Copy Markdown

Simple version of a --validate option for the CLI added by highjacking the -c option code.

Sort-of delivers #72

@ravi

ravi commented Feb 9, 2015

Copy link
Copy Markdown

Can we have this? (please!)

@AVGP

AVGP commented Feb 9, 2015

Copy link
Copy Markdown
Author

@ravi You can use my branch (referenced in this pull request) to try it :) I'm waiting for feedback or a merge on this, too

@aseemk

aseemk commented Feb 9, 2015

Copy link
Copy Markdown
Member

Whoops, I totally missed this PR, sorry about that! Taking a quick look now.

@ravi

ravi commented Feb 9, 2015

Copy link
Copy Markdown

@AVGP Unfortunately I might have misunderstood your commit... I had hoped for more context for the error message, but it seems to me your change does not provide that.

@ravi

ravi commented Feb 9, 2015

Copy link
Copy Markdown

For my ~ 600 line JSON5 config file, the below is mostly useless as an error report, I am afraid:

/tmp/node_modules/json5/lib/json5.js:54
            throw error;
                  ^
SyntaxError: Expected ']' instead of '{'

Comment thread lib/cli.js

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of referencing args[2] in multiple spots, let's add a variable to save it, e.g. cmd after args.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, is this boolean logic right? I thought && takes precedence over ||, so you might need to wrap the -c || --validate check in parentheses.

@aseemk

aseemk commented Feb 9, 2015

Copy link
Copy Markdown
Member

Nice work otherwise @AVGP. Thank you for the pull request! =)

@aseemk

aseemk commented Feb 9, 2015

Copy link
Copy Markdown
Member

Good point @ravi. So this won't fix that. Please feel free to open a new issue to add line and column number to syntax error messages. Hopefully it won't be too hard for someone to take a stab at.

@ravi

ravi commented Feb 9, 2015

Copy link
Copy Markdown

Created #86 . Thanks.

@jordanbtucker

Copy link
Copy Markdown
Member

Fixed in 35269da

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants