better CLI and fixes
This commit is contained in:
parent
7bf795b455
commit
1d710c0356
2 changed files with 21 additions and 4 deletions
|
|
@ -7,7 +7,7 @@ import (
|
|||
"oss.terrastruct.com/d2/d2themes"
|
||||
)
|
||||
|
||||
var Catalog = []d2themes.Theme{
|
||||
var LightCatalog = []d2themes.Theme{
|
||||
NeutralDefault,
|
||||
NeutralGrey,
|
||||
FlagshipTerrastruct,
|
||||
|
|
@ -22,11 +22,20 @@ var Catalog = []d2themes.Theme{
|
|||
EarthTones,
|
||||
EvergladeGreen,
|
||||
ButteredToast,
|
||||
}
|
||||
|
||||
var DarkCatalog = []d2themes.Theme{
|
||||
DarkMauve,
|
||||
}
|
||||
|
||||
func Find(id int64) d2themes.Theme {
|
||||
for _, theme := range Catalog {
|
||||
for _, theme := range LightCatalog {
|
||||
if theme.ID == id {
|
||||
return theme
|
||||
}
|
||||
}
|
||||
|
||||
for _, theme := range DarkCatalog {
|
||||
if theme.ID == id {
|
||||
return theme
|
||||
}
|
||||
|
|
@ -37,8 +46,16 @@ func Find(id int64) d2themes.Theme {
|
|||
|
||||
func CLIString() string {
|
||||
var s strings.Builder
|
||||
for _, t := range Catalog {
|
||||
|
||||
s.WriteString("Light:\n")
|
||||
for _, t := range LightCatalog {
|
||||
s.WriteString(fmt.Sprintf("- %s: %d\n", t.Name, t.ID))
|
||||
}
|
||||
|
||||
s.WriteString("Dark:\n")
|
||||
for _, t := range DarkCatalog {
|
||||
s.WriteString(fmt.Sprintf("- %s: %d\n", t.Name, t.ID))
|
||||
}
|
||||
|
||||
return s.String()
|
||||
}
|
||||
|
|
|
|||
2
main.go
2
main.go
|
|
@ -68,7 +68,7 @@ func run(ctx context.Context, ms *xmain.State) (err error) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
darkThemeFlag, err := ms.Opts.Int64("D2_D_THEME", "dark_theme", "", -1, "the diagram dark theme ID. When left unset only the theme will be applied")
|
||||
darkThemeFlag, err := ms.Opts.Int64("D2_D_THEME", "dark-theme", "", -1, "the diagram dark theme ID. When left unset only the theme will be applied")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue