improve validate usage message#552
Conversation
|
On Thu, Sep 01, 2016 at 05:17:23AM -0700, x1022as wrote:
Lots of commands (e.g. cat) block if they expect input on stdin and |
|
@wking thanks for reviewing. I'm not sure if this can make sense :) |
|
On Thu, Sep 01, 2016 at 05:10:31PM -0700, x1022as wrote:
It doesn't do anything about attaching it to a pipe, it just errors
I haven't dug in enough to figure out how to programmatically write to My point is that I don't think “special handling when stdin is a
I agree that is a situation that will happen, but don't think it will |
|
@wking that make sense, and I think a better usage would help a lot;) |
|
On Thu, Sep 01, 2016 at 11:13:39PM -0700, x1022as wrote:
Agreed. I'd be fine with using an actual command-line-argument |
|
@wking sorry for late response, validate seems to be very simple for now, I am not sure if we need a cli library here. cobra(as docker and runc use it) may be a little bit complex for this. |
|
Why don't we just follow every other CLI and make it so that if you specify |
|
On Mon, Sep 05, 2016 at 05:39:40AM -0700, x1022as wrote:
I haven't seen cobra used before, but urfave/cli is pretty simple 1. |
|
On Mon, Sep 05, 2016 at 06:19:32AM -0700, Aleksa Sarai wrote:
I think the pattern is “default to reading from stdin, unless a file file In that case, I don't see the point of bothering with the special ‘-’. Or are you suggesting we only support ‘-’ for stdin and error out if
Agreed. |
db70d1e to
9a0a926
Compare
|
validate now works as following: ping |
schema/validate.go
Outdated
| cli.StringFlag{ | ||
| Name: "schema,s", | ||
| Value: "", | ||
| Usage: "specify the schema-json file", |
There was a problem hiding this comment.
There's no validation without a schema, so I'd rather keep this as a positional parameter (and not make it an option).
|
@vbatts you're the primary author of this script 😄 What're your thoughts on introducing |
schema/validate.go
Outdated
| result, err := gojsonschema.Validate(schemaLoader, documentLoader) | ||
| if err != nil { | ||
| panic(err.Error()) | ||
| return fmt.Errorf("Error: json validate error: %s", err) |
There was a problem hiding this comment.
nit: "Error: json..." -> "json..."
|
I'm not terribly opposed to this. I know |
|
side-note: i reckon we need to vendor |
|
ping @vbatts to make a decision :) I'd vote for not having any dependencies in this repo. Keep it minimal. |
|
dang @crosbymichael . I though you loved urfave/cli. @x1022as can we do this feature without pulling in the urfave/cli repo please. |
|
@vbatts I do love it but sometimes simple is better, I think for the needsd we have, its good to leave out in this repo. |
|
@vbatts of course, will do this later :) |
|
updated |
this commit contains: * add explicit usage message to validate * schemaPath was overrided by filepath.Abs(), schemaLoader would not get * the abs path. * check local scheme and document file path with os.Stat() Signed-off-by: Deng Guangxing <[email protected]>
|
This pr contains:
|
add usage message to validate:
'cat document.json | validate schema.json'
validate would block in such case:
'validate schema.json'
add stdin status check to avoid this.
Signed-off-by: Deng Guangxing [email protected]
before:
after: