From 4e8e4612bd20ed12fa4b64f825f050e45ce5f9bd Mon Sep 17 00:00:00 2001 From: Denis Isaev Date: Sat, 24 Nov 2018 12:15:54 +0300 Subject: [PATCH] fix 'main' redefinition in scripts/ dir --- scripts/generate_cheatsheet.go | 54 ------------------- .../main.go} | 2 +- 2 files changed, 1 insertion(+), 55 deletions(-) delete mode 100644 scripts/generate_cheatsheet.go rename scripts/{push_new_patch.go => push_new_patch/main.go} (97%) diff --git a/scripts/generate_cheatsheet.go b/scripts/generate_cheatsheet.go deleted file mode 100644 index cfa6d92ad..000000000 --- a/scripts/generate_cheatsheet.go +++ /dev/null @@ -1,54 +0,0 @@ -// 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 ( - "fmt" - "os" - "strings" - - "github.com/jesseduffield/lazygit/pkg/app" - "github.com/jesseduffield/lazygit/pkg/config" - "github.com/jesseduffield/lazygit/pkg/utils" -) - -func main() { - appConfig, _ := config.NewAppConfig("", "", "", "", "", new(bool)) - a, _ := app.NewApp(appConfig) - lang := a.Tr.GetLanguage() - name := "Keybindings_" + lang + ".md" - bindings := a.Gui.GetKeybindings() - padWidth := a.Gui.GetMaxKeyLength(bindings) - file, _ := os.Create(name) - current := "v" - content := "" - title := "" - - file.WriteString("# Lazygit " + a.Tr.SLocalize("menu")) - - for _, binding := range bindings { - if key := a.Gui.GetKey(binding); key != "" && (binding.Description != "" || key == "x") { - if binding.ViewName != current { - current = binding.ViewName - if current == "" { - title = a.Tr.SLocalize("GlobalTitle") - } else { - title = a.Tr.SLocalize(strings.Title(current) + "Title") - } - content = fmt.Sprintf("\n\n## %s\n
\n", title)
-				file.WriteString(content)
-			}
-			// workaround to include menu keybinding in cheatsheet
-			// could not add this Description field directly to keybindings.go,
-			// because then menu key would be displayed in menu itself and that is undesirable
-			if key == "x" {
-				binding.Description = a.Tr.SLocalize("menu")
-			}
-			content = fmt.Sprintf("\t%s%s  %s\n", key, strings.TrimPrefix(utils.WithPadding(key, padWidth), key), binding.Description)
-			file.WriteString(content)
-		}
-	}
-}
diff --git a/scripts/push_new_patch.go b/scripts/push_new_patch/main.go
similarity index 97%
rename from scripts/push_new_patch.go
rename to scripts/push_new_patch/main.go
index e11865fff..b1660d3c1 100755
--- a/scripts/push_new_patch.go
+++ b/scripts/push_new_patch/main.go
@@ -1,5 +1,5 @@
 // call from project root with
-// go run bin/push_new_patch.go
+// go run scripts/push_new_patch/main.go
 
 // goreleaser expects a $GITHUB_TOKEN env variable to be defined
 // in order to push the release got github