-
Notifications
You must be signed in to change notification settings - Fork 524
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
cli: add validate command #2415
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for taking this!
For the error case, can we just print out the errors without "failed to validate"? Technically, it successfully validated it to be incorrect.
For success, I always like printing something out to let users know their command worked. "Success! [x.d2] is valid D2."
Can you add a test to e2etests-cli please?
ci/release/template/man/d2.1
Outdated
@@ -162,6 +164,8 @@ Lists available themes | |||
Format all passed files | |||
.It Ar play Ar file.d2 | |||
Opens the file in playground, an online web viewer (https://play.d2lang.com) | |||
.It Ar validate Ar file.d2 | |||
Validate all input file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Validates file.d2"
d2cli/help.go
Outdated
@@ -40,6 +41,7 @@ Subcommands: | |||
%[1]s themes - Lists available themes | |||
%[1]s fmt file.d2 ... - Format passed files | |||
%[1]s play file.d2 - Opens the file in playground, an online web viewer (https://play.d2lang.com) | |||
%[1]s validate file.d2 - Validate input file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validates file.d2
d2cli/validate.go
Outdated
|
||
ms.Opts = xmain.NewOpts(ms.Env, ms.Opts.Flags.Args()[1:]) | ||
if len(ms.Opts.Args) == 0 { | ||
return xmain.UsageErrorf("validate must be passed an input file to be validated") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the "to be validated" please
Yeah, we should be able to do that.
Sure, I also thought about that, for better ux.
I'll look into it. |
Hey @alixander, should we print "Success! input is valid D2." in case of |
/fixes #2410