use float for flag
This commit is contained in:
parent
5ea81a5b90
commit
65059546eb
2 changed files with 7 additions and 8 deletions
|
|
@ -80,7 +80,7 @@ Renders the diagram to look like it was sketched by hand
|
||||||
.It Fl -center Ar flag
|
.It Fl -center Ar flag
|
||||||
Center the SVG in the containing viewbox, such as your browser screen
|
Center the SVG in the containing viewbox, such as your browser screen
|
||||||
.Ns .
|
.Ns .
|
||||||
.It Fl -scale Ar fit
|
.It Fl -scale Ar -1
|
||||||
Set a fixed render scale (e.g. 0.5 to halve rendered size). If none provided, SVG will fit to screen
|
Set a fixed render scale (e.g. 0.5 to halve rendered size). If none provided, SVG will fit to screen
|
||||||
.Ns .
|
.Ns .
|
||||||
.It Fl -font-regular
|
.It Fl -font-regular
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,10 @@ func Run(ctx context.Context, ms *xmain.State) (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
scaleFlag := ms.Opts.String("SCALE", "scale", "", "fit", "set a fixed render scale (e.g. 0.5 to halve rendered size). If none provided, SVG will fit to screen.")
|
scaleFlag, err := ms.Opts.Float64("SCALE", "scale", "", -1, "set a fixed render scale (e.g. 0.5 to halve rendered size). If none provided, SVG will fit to screen.")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
fontRegularFlag := ms.Opts.String("D2_FONT_REGULAR", "font-regular", "", "", "path to .ttf file to use for the regular font. If none provided, Source Sans Pro Regular is used.")
|
fontRegularFlag := ms.Opts.String("D2_FONT_REGULAR", "font-regular", "", "", "path to .ttf file to use for the regular font. If none provided, Source Sans Pro Regular is used.")
|
||||||
fontItalicFlag := ms.Opts.String("D2_FONT_ITALIC", "font-italic", "", "", "path to .ttf file to use for the italic font. If none provided, Source Sans Pro Regular-Italic is used.")
|
fontItalicFlag := ms.Opts.String("D2_FONT_ITALIC", "font-italic", "", "", "path to .ttf file to use for the italic font. If none provided, Source Sans Pro Regular-Italic is used.")
|
||||||
|
|
@ -234,12 +237,8 @@ func Run(ctx context.Context, ms *xmain.State) (err error) {
|
||||||
ms.Log.Debug.Printf("using dark theme %s (ID: %d)", match.Name, *darkThemeFlag)
|
ms.Log.Debug.Printf("using dark theme %s (ID: %d)", match.Name, *darkThemeFlag)
|
||||||
}
|
}
|
||||||
var scale *float64
|
var scale *float64
|
||||||
if scaleFlag != nil && *scaleFlag != "fit" {
|
if scaleFlag != nil && *scaleFlag > 0. {
|
||||||
f, err := strconv.ParseFloat(*scaleFlag, 64)
|
scale = scaleFlag
|
||||||
if err != nil || f <= 0. {
|
|
||||||
return xmain.UsageErrorf("-scale must a positive floating point number or \"fit\".")
|
|
||||||
}
|
|
||||||
scale = &f
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin, err := d2plugin.FindPlugin(ctx, ps, *layoutFlag)
|
plugin, err := d2plugin.FindPlugin(ctx, ps, *layoutFlag)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue