pr292: Review fixes
This commit is contained in:
parent
f7623a2057
commit
cdffedb9df
6 changed files with 10 additions and 10 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#### Features 🚀
|
||||
|
||||
- autoformat is supported on the CLI with the `fmt` subcommand.
|
||||
- Formatting of d2 scripts is supported on the CLI with the `fmt` subcommand.
|
||||
[#292](https://github.com/terrastruct/d2/pull/292)
|
||||
- Latex is now supported. See [docs](https://d2lang.com/tour/text) for more.
|
||||
[#229](https://github.com/terrastruct/d2/pull/229)
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ Lists available layout engine options with short help.
|
|||
.It Ar layout Op Ar name
|
||||
Display long help for a particular layout engine.
|
||||
.It Ar fmt Ar file.d2
|
||||
Autoformat
|
||||
Format
|
||||
.Ar file.d2
|
||||
.Ns .
|
||||
.El
|
||||
|
|
|
|||
2
ci/sub
2
ci/sub
|
|
@ -1 +1 @@
|
|||
Subproject commit 702b771228f41e5485b5f3f593ce79f6efcb555d
|
||||
Subproject commit a39a678570a0454d6bf63f9012fb5ec107e24df5
|
||||
|
|
@ -11,14 +11,14 @@ import (
|
|||
"oss.terrastruct.com/d2/lib/xmain"
|
||||
)
|
||||
|
||||
func autofmt(ctx context.Context, ms *xmain.State) (err error) {
|
||||
defer xdefer.Errorf(&err, "autofmt failed")
|
||||
func fmtCmd(ctx context.Context, ms *xmain.State) (err error) {
|
||||
defer xdefer.Errorf(&err, "failed to fmt")
|
||||
|
||||
ms.Opts = xmain.NewOpts(ms.Env, ms.Log, ms.Opts.Flags.Args()[1:])
|
||||
if len(ms.Opts.Args) == 0 {
|
||||
return xmain.UsageErrorf("fmt must be passed the file to be formatted")
|
||||
} else if len(ms.Opts.Args) > 1 {
|
||||
return xmain.UsageErrorf("fmt only accepts one argument for the file to be formatted")
|
||||
return xmain.UsageErrorf("fmt accepts only one argument for the file to be formatted")
|
||||
}
|
||||
|
||||
inputPath := ms.Opts.Args[0]
|
||||
4
help.go
4
help.go
|
|
@ -32,13 +32,13 @@ 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
|
||||
%[1]s fmt file.d2 - Autoformat file.d2
|
||||
%[1]s fmt file.d2 - Format file.d2
|
||||
|
||||
See more docs and the source code at https://oss.terrastruct.com/d2
|
||||
`, filepath.Base(ms.Name), ms.Opts.Defaults())
|
||||
}
|
||||
|
||||
func layoutHelp(ctx context.Context, ms *xmain.State) error {
|
||||
func layoutCmd(ctx context.Context, ms *xmain.State) error {
|
||||
if len(ms.Opts.Flags.Args()) == 1 {
|
||||
return shortLayoutHelp(ctx, ms)
|
||||
} else if len(ms.Opts.Flags.Args()) == 2 {
|
||||
|
|
|
|||
4
main.go
4
main.go
|
|
@ -73,9 +73,9 @@ func run(ctx context.Context, ms *xmain.State) (err error) {
|
|||
if len(ms.Opts.Flags.Args()) > 0 {
|
||||
switch ms.Opts.Flags.Arg(0) {
|
||||
case "layout":
|
||||
return layoutHelp(ctx, ms)
|
||||
return layoutCmd(ctx, ms)
|
||||
case "fmt":
|
||||
return autofmt(ctx, ms)
|
||||
return fmtCmd(ctx, ms)
|
||||
case "version":
|
||||
if len(ms.Opts.Flags.Args()) > 1 {
|
||||
return xmain.UsageErrorf("version subcommand accepts no arguments")
|
||||
|
|
|
|||
Loading…
Reference in a new issue