diff --git a/ci/release/template/man/d2.1 b/ci/release/template/man/d2.1 index eb888c57c..08eb02c0e 100644 --- a/ci/release/template/man/d2.1 +++ b/ci/release/template/man/d2.1 @@ -18,7 +18,7 @@ .Nm d2 .Ar play Ar file.d2 .Nm d2 -.Ar validate Ar file.d2 ... +.Ar validate Ar file.d2 .Sh DESCRIPTION .Nm compiles and renders @@ -164,8 +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 files +.It Ar validate Ar file.d2 +Validate all input file .El .Sh ENVIRONMENT VARIABLES Many flags can also be set with environment variables. diff --git a/d2cli/help.go b/d2cli/help.go index 6b95a2c33..faa5ba6f8 100644 --- a/d2cli/help.go +++ b/d2cli/help.go @@ -23,7 +23,7 @@ Usage: %[1]s layout [name] %[1]s fmt file.d2 ... %[1]s play [--theme=0] [--sketch] file.d2 - %[1]s validate file.d2 ... + %[1]s validate file.d2 %[1]s compiles and renders file.d2 to file.svg | file.png It defaults to file.svg if an output path is not provided. @@ -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 files + %[1]s validate file.d2 - Validate input file 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 29840ef5b..b62aec2ed 100644 --- a/d2cli/validate.go +++ b/d2cli/validate.go @@ -13,23 +13,22 @@ func validateCmd(ctx context.Context, ms *xmain.State) (err error) { ms.Opts = xmain.NewOpts(ms.Env, ms.Opts.Flags.Args()[1:]) if len(ms.Opts.Args) == 0 { - return xmain.UsageErrorf("validate must be passed at least one file to be validated") + return xmain.UsageErrorf("validate must be passed an input file to be validated") } - for _, inputPath := range ms.Opts.Args { - if inputPath != "-" { - inputPath = ms.AbsPath(inputPath) - } + inputPath := ms.Opts.Args[0] + if inputPath != "-" { + inputPath = ms.AbsPath(inputPath) + } - input, err := ms.ReadPath(inputPath) - if err != nil { - return err - } + input, err := ms.ReadPath(inputPath) + if err != nil { + return err + } - _, err = d2lib.Parse(ctx, string(input), nil) - if err != nil { - return err - } + _, err = d2lib.Parse(ctx, string(input), nil) + if err != nil { + return err } return nil }