updated text changes

This commit is contained in:
melsonic 2025-03-11 00:48:43 +05:30 committed by melsonic
parent 20ecd634cc
commit 61ba9132dd
No known key found for this signature in database
GPG key ID: DFA426742F621CD7
4 changed files with 12 additions and 4 deletions

View file

@ -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.

View file

@ -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.

View file

@ -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
}

View file

@ -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()