d2 icon indicating copy to clipboard operation
d2 copied to clipboard

Validate command

Open cllns opened this issue 10 months ago • 1 comments

Hi there!

I'm working on using D2 in my codebase, and in my tests I'd like to just parse the file to validate that the d2 code generated is valid, without actually generating a file.

I ended up implementing this as d2 graph.d2 /dev/null, which works but I think a CLI option would be better since many people don't know about /dev/null

cllns avatar Mar 05 '25 20:03 cllns

Ah that's a good idea.

I think instead of a flag, this could just serve as its own command. d2 validate input.d2.

alixander avatar Mar 05 '25 21:03 alixander

Hey @alixander, I am working on this one & I have a few questions.

  1. Should this command support multiple files streamlined together or a single file.
  2. Do I need to print something if the file is valid? like "inputPath is valid"

melsonic avatar Mar 09 '25 14:03 melsonic

@melsonic Awesome!

  1. I think just 1 file is fine.
  2. It can print out the errors

alixander avatar Mar 09 '25 22:03 alixander