update cli docs
This commit is contained in:
parent
3f8e752968
commit
bec0332619
3 changed files with 13 additions and 3 deletions
|
|
@ -64,8 +64,7 @@ Port listening address when used with
|
|||
.Ar watch
|
||||
.Ns .
|
||||
.It Fl t , -theme Ar 0
|
||||
Set the diagram theme to the passed integer. For a list of available options, see
|
||||
.Lk https://oss.terrastruct.com/d2
|
||||
Set the diagram theme ID
|
||||
.Ns .
|
||||
.It Fl s , -sketch Ar false
|
||||
Renders the diagram to look like it was sketched by hand
|
||||
|
|
@ -92,6 +91,8 @@ Print version information and exit.
|
|||
Lists available layout engine options with short help.
|
||||
.It Ar layout Op Ar name
|
||||
Display long help for a particular layout engine, including its configuration options.
|
||||
.It Ar themes
|
||||
Lists available themes.
|
||||
.It Ar fmt Ar file.d2 ...
|
||||
Format all passed files.
|
||||
.El
|
||||
|
|
|
|||
6
help.go
6
help.go
|
|
@ -12,6 +12,7 @@ import (
|
|||
"oss.terrastruct.com/util-go/xmain"
|
||||
|
||||
"oss.terrastruct.com/d2/d2plugin"
|
||||
"oss.terrastruct.com/d2/d2themes/d2themescatalog"
|
||||
)
|
||||
|
||||
func help(ms *xmain.State) {
|
||||
|
|
@ -33,6 +34,7 @@ Flags:
|
|||
Subcommands:
|
||||
%[1]s layout - Lists available layout engine options with short help
|
||||
%[1]s layout [name] - Display long help for a particular layout engine, including its configuration options
|
||||
%[1]s themes - Lists available themes
|
||||
%[1]s fmt file.d2 ... - Format passed files
|
||||
|
||||
See more docs and the source code at https://oss.terrastruct.com/d2.
|
||||
|
|
@ -51,6 +53,10 @@ func layoutCmd(ctx context.Context, ms *xmain.State, ps []d2plugin.Plugin) error
|
|||
}
|
||||
}
|
||||
|
||||
func themesCmd(ctx context.Context, ms *xmain.State) {
|
||||
fmt.Fprintf(ms.Stdout, "Available themes:\n%s", d2themescatalog.CLIString())
|
||||
}
|
||||
|
||||
func shortLayoutHelp(ctx context.Context, ms *xmain.State, ps []d2plugin.Plugin) error {
|
||||
var pluginLines []string
|
||||
pinfos, err := d2plugin.ListPluginInfos(ctx, ps)
|
||||
|
|
|
|||
5
main.go
5
main.go
|
|
@ -60,7 +60,7 @@ func run(ctx context.Context, ms *xmain.State) (err error) {
|
|||
return err
|
||||
}
|
||||
layoutFlag := ms.Opts.String("D2_LAYOUT", "layout", "l", "dagre", `the layout engine used`)
|
||||
themeFlag, err := ms.Opts.Int64("D2_THEME", "theme", "t", 0, "the diagram theme ID. For a list of available options, see https://oss.terrastruct.com/d2")
|
||||
themeFlag, err := ms.Opts.Int64("D2_THEME", "theme", "t", 0, "the diagram theme ID")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -102,6 +102,9 @@ func run(ctx context.Context, ms *xmain.State) (err error) {
|
|||
return initPlaywright()
|
||||
case "layout":
|
||||
return layoutCmd(ctx, ms, ps)
|
||||
case "themes":
|
||||
themesCmd(ctx, ms)
|
||||
return nil
|
||||
case "fmt":
|
||||
return fmtCmd(ctx, ms)
|
||||
case "version":
|
||||
|
|
|
|||
Loading…
Reference in a new issue