From 61ba9132dd6c6aa0474d736c8c41039fd1a72c5e Mon Sep 17 00:00:00 2001 From: melsonic Date: Tue, 11 Mar 2025 00:48:43 +0530 Subject: [PATCH] updated text changes --- ci/release/template/man/d2.1 | 2 +- d2cli/help.go | 2 +- d2cli/validate.go | 11 +++++++++-- d2cli/watch.go | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ci/release/template/man/d2.1 b/ci/release/template/man/d2.1 index 08eb02c0e..70269172b 100644 --- a/ci/release/template/man/d2.1 +++ b/ci/release/template/man/d2.1 @@ -165,7 +165,7 @@ 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 +Validates file.d2 .El .Sh ENVIRONMENT VARIABLES Many flags can also be set with environment variables. diff --git a/d2cli/help.go b/d2cli/help.go index faa5ba6f8..5b025b6bb 100644 --- a/d2cli/help.go +++ b/d2cli/help.go @@ -41,7 +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 + %[1]s validate file.d2 - Validates file.d2 See more docs and the source code at https://oss.terrastruct.com/d2. Hosted icons at https://icons.terrastruct.com. diff --git a/d2cli/validate.go b/d2cli/validate.go index b62aec2ed..ba118e0f9 100644 --- a/d2cli/validate.go +++ b/d2cli/validate.go @@ -2,6 +2,7 @@ package d2cli import ( "context" + "fmt" "oss.terrastruct.com/d2/d2lib" "oss.terrastruct.com/util-go/xdefer" @@ -9,11 +10,11 @@ import ( ) func validateCmd(ctx context.Context, ms *xmain.State) (err error) { - defer xdefer.Errorf(&err, "failed to validate") + defer xdefer.Errorf(&err, "") 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") + return xmain.UsageErrorf("validate must be passed an input file") } inputPath := ms.Opts.Args[0] @@ -30,5 +31,11 @@ func validateCmd(ctx context.Context, ms *xmain.State) (err error) { if err != nil { return err } + + if inputPath == "-" { + inputPath = "Input" + } + + fmt.Printf("Success! [%s] is valid D2.\n", inputPath) return nil } diff --git a/d2cli/watch.go b/d2cli/watch.go index 6c240a711..458c7cd28 100644 --- a/d2cli/watch.go +++ b/d2cli/watch.go @@ -438,6 +438,7 @@ func (w *watcher) compileLoop(ctx context.Context) error { if len(svg) > 0 { err = fmt.Errorf("failed to fully %scompile (rendering partial svg): %w", recompiledPrefix, err) } else { + fmt.Println(recompiledPrefix) err = fmt.Errorf("failed to %scompile: %w", recompiledPrefix, err) } errs = err.Error()