Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: display version #1400

Merged
merged 2 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

#### Improvements 🧹

- Display version on CLI help invocation [#1400](https://github.com/terrastruct/d2/pull/1400)

#### Bugfixes ⛑️
8 changes: 5 additions & 3 deletions d2cli/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import (

"oss.terrastruct.com/d2/d2plugin"
"oss.terrastruct.com/d2/d2themes/d2themescatalog"
"oss.terrastruct.com/d2/lib/version"
)

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 layout [name]
%[1]s fmt file.d2 ...
Expand All @@ -29,7 +31,7 @@ Use - to have d2 read from stdin or write to stdout.
See man d2 for more detailed docs.

Flags:
%s
%[3]s

Subcommands:
%[1]s layout - Lists available layout engine options with short help
Expand All @@ -40,7 +42,7 @@ Subcommands:
See more docs and the source code at https://oss.terrastruct.com/d2.
Hosted icons at https://icons.terrastruct.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 {
Expand Down