mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
add generate_cheatsheet script
script is generating markdown document with small cheatsheet in selected language
This commit is contained in:
parent
1fa55875e2
commit
359636c1aa
3 changed files with 58 additions and 13 deletions
41
scripts/generate_cheatsheet.go
Normal file
41
scripts/generate_cheatsheet.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
// run:
|
||||
// LANG=en go run generate_cheatsheet.go
|
||||
// to generate Keybindings_en.md file in current directory
|
||||
// change LANG to generate cheatsheet in different language (if supported)
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/app"
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
appConfig, _ := config.NewAppConfig("", "", "", "", "", new(bool))
|
||||
a, _ := app.NewApp(appConfig)
|
||||
lang := a.Tr.GetLanguage()
|
||||
name := "Keybindings_" + lang + ".md"
|
||||
bindings := a.Gui.GetKeybindings()
|
||||
file, _ := os.Create(name)
|
||||
current := ""
|
||||
content := ""
|
||||
|
||||
file.WriteString("# Lazygit " + a.Tr.SLocalize("help"))
|
||||
|
||||
for _, binding := range bindings {
|
||||
if key := a.Gui.GetKey(binding); key != "" && binding.Description != "" {
|
||||
if binding.ViewName != current {
|
||||
current = binding.ViewName
|
||||
title := a.Tr.SLocalize(strings.Title(current) + "Title")
|
||||
content = fmt.Sprintf("</pre>\n\n## %s\n<pre>\n", title)
|
||||
file.WriteString(content)
|
||||
}
|
||||
content = fmt.Sprintf("\t<kbd>%s</kbd>:\t%s\n", key, binding.Description)
|
||||
file.WriteString(content)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue