diff options
author | Dawid Dziurla <dawidd0811@gmail.com> | 2018-09-01 16:50:22 +0200 |
---|---|---|
committer | Dawid Dziurla <dawidd0811@gmail.com> | 2018-09-03 17:54:06 +0200 |
commit | 359636c1aa394bf8b619a7287f504e6afcf11470 (patch) | |
tree | a9ec5c0a8beba2f874d63e3ffebd64d18ee0851c /scripts | |
parent | 1fa55875e2487e9b5d9ec910a1b7a5da795333d9 (diff) |
add generate_cheatsheet script
script is generating markdown document with small cheatsheet
in selected language
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/generate_cheatsheet.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/scripts/generate_cheatsheet.go b/scripts/generate_cheatsheet.go new file mode 100644 index 000000000..87ebe43c5 --- /dev/null +++ b/scripts/generate_cheatsheet.go @@ -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) + } + } +} |