Merge pull request #1400 from alixander/display-version

cli: display version
This commit is contained in:
Alexander Wang 2023-06-12 01:27:43 -07:00 committed by GitHub
commit 34dfae6b5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -2,4 +2,6 @@
#### Improvements 🧹 #### Improvements 🧹
- Display version on CLI help invocation [#1400](https://github.com/terrastruct/d2/pull/1400)
#### Bugfixes ⛑️ #### Bugfixes ⛑️

View file

@ -13,10 +13,12 @@ import (
"oss.terrastruct.com/d2/d2plugin" "oss.terrastruct.com/d2/d2plugin"
"oss.terrastruct.com/d2/d2themes/d2themescatalog" "oss.terrastruct.com/d2/d2themes/d2themescatalog"
"oss.terrastruct.com/d2/lib/version"
) )
func help(ms *xmain.State) { func help(ms *xmain.State) {
fmt.Fprintf(ms.Stdout, `Usage: fmt.Fprintf(ms.Stdout, `%[1]s %[2]s
Usage:
%[1]s [--watch=false] [--theme=0] file.d2 [file.svg | file.png] %[1]s [--watch=false] [--theme=0] file.d2 [file.svg | file.png]
%[1]s layout [name] %[1]s layout [name]
%[1]s fmt file.d2 ... %[1]s fmt file.d2 ...
@ -29,7 +31,7 @@ Use - to have d2 read from stdin or write to stdout.
See man d2 for more detailed docs. See man d2 for more detailed docs.
Flags: Flags:
%s %[3]s
Subcommands: Subcommands:
%[1]s layout - Lists available layout engine options with short help %[1]s layout - Lists available layout engine options with short help
@ -40,7 +42,7 @@ Subcommands:
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.
Playground runner at https://play.d2lang.com. Playground runner at https://play.d2lang.com.
`, filepath.Base(ms.Name), ms.Opts.Defaults()) `, filepath.Base(ms.Name), version.Version, ms.Opts.Defaults())
} }
func layoutCmd(ctx context.Context, ms *xmain.State, ps []d2plugin.Plugin) error { func layoutCmd(ctx context.Context, ms *xmain.State, ps []d2plugin.Plugin) error {