updated text changes
This commit is contained in:
parent
20ecd634cc
commit
61ba9132dd
4 changed files with 12 additions and 4 deletions
|
|
@ -165,7 +165,7 @@ Format all passed files
|
||||||
.It Ar play Ar file.d2
|
.It Ar play Ar file.d2
|
||||||
Opens the file in playground, an online web viewer (https://play.d2lang.com)
|
Opens the file in playground, an online web viewer (https://play.d2lang.com)
|
||||||
.It Ar validate Ar file.d2
|
.It Ar validate Ar file.d2
|
||||||
Validate all input file
|
Validates file.d2
|
||||||
.El
|
.El
|
||||||
.Sh ENVIRONMENT VARIABLES
|
.Sh ENVIRONMENT VARIABLES
|
||||||
Many flags can also be set with environment variables.
|
Many flags can also be set with environment variables.
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ Subcommands:
|
||||||
%[1]s themes - Lists available themes
|
%[1]s themes - Lists available themes
|
||||||
%[1]s fmt file.d2 ... - Format passed files
|
%[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 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.
|
See more docs and the source code at https://oss.terrastruct.com/d2.
|
||||||
Hosted icons at https://icons.terrastruct.com.
|
Hosted icons at https://icons.terrastruct.com.
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package d2cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"oss.terrastruct.com/d2/d2lib"
|
"oss.terrastruct.com/d2/d2lib"
|
||||||
"oss.terrastruct.com/util-go/xdefer"
|
"oss.terrastruct.com/util-go/xdefer"
|
||||||
|
|
@ -9,11 +10,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func validateCmd(ctx context.Context, ms *xmain.State) (err error) {
|
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:])
|
ms.Opts = xmain.NewOpts(ms.Env, ms.Opts.Flags.Args()[1:])
|
||||||
if len(ms.Opts.Args) == 0 {
|
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]
|
inputPath := ms.Opts.Args[0]
|
||||||
|
|
@ -30,5 +31,11 @@ func validateCmd(ctx context.Context, ms *xmain.State) (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if inputPath == "-" {
|
||||||
|
inputPath = "Input"
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Success! [%s] is valid D2.\n", inputPath)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -438,6 +438,7 @@ func (w *watcher) compileLoop(ctx context.Context) error {
|
||||||
if len(svg) > 0 {
|
if len(svg) > 0 {
|
||||||
err = fmt.Errorf("failed to fully %scompile (rendering partial svg): %w", recompiledPrefix, err)
|
err = fmt.Errorf("failed to fully %scompile (rendering partial svg): %w", recompiledPrefix, err)
|
||||||
} else {
|
} else {
|
||||||
|
fmt.Println(recompiledPrefix)
|
||||||
err = fmt.Errorf("failed to %scompile: %w", recompiledPrefix, err)
|
err = fmt.Errorf("failed to %scompile: %w", recompiledPrefix, err)
|
||||||
}
|
}
|
||||||
errs = err.Error()
|
errs = err.Error()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue