diff options
| author | Nikolaus Gotsche <n@softwarefools.com> | 2019-01-27 16:15:12 +0100 |
|---|---|---|
| committer | Nikolaus Gotsche <n@softwarefools.com> | 2019-01-27 16:15:12 +0100 |
| commit | af4c5d48fd3c56793d59595045a069a178346652 (patch) | |
| tree | f39ef02539cf469ba274b0ba8265216b18ced38f /main.go | |
| parent | 32ed5a2d05b8266b2dd00844dc7b52b3cb91114d (diff) | |
Commandline options and cleaned parsing options. no wraping of text0.2
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 68 |
1 files changed, 59 insertions, 9 deletions
@@ -1,11 +1,13 @@ package main import ( - //"fmt" + "fmt" "os" "bufio" "strings" + "github.com/pborman/getopt/v2" + "github.com/aarzilli/nucular" _"github.com/aarzilli/nucular/label" nstyle "github.com/aarzilli/nucular/style" @@ -16,7 +18,12 @@ var ( Wnd nucular.MasterWindow theme nstyle.Theme = nstyle.DarkTheme dat []data - hea string + interArgs []string + hea,filename,themestr string + help, border, resize, move, scroll, menubar bool + + version string + compdate string ) type data struct { @@ -25,15 +32,53 @@ type data struct { textr []string } +func init() { + filename = "none" + getopt.FlagLong(&border, "no-border", 'b', "Remove Borders") + getopt.FlagLong(&resize, "no-resize", 'r', "Prohibit resizing") + getopt.FlagLong(&move, "no-translate", 't', "Prohibit window moving") + getopt.FlagLong(&scroll, "no-scroll", 's', "Prohibit scrollibars") + getopt.FlagLong(&menubar, "no-menu", 'm', "Dont Show Menu") + getopt.FlagLong(&scaling, "magnify", 'g', "Magnification level") + getopt.FlagLong(&themestr, "color-theme", 'c', "Specify Theme") + getopt.FlagLong(&help, "help", 'h', "Show Program Usage") + getopt.FlagLong(&filename, "file", 'f', "The textfile to be parsed and displayed") + +} func main() { + getopt.Parse() + interArgs = getopt.Args() + + border = !border + resize = !resize + move = !move + scroll = !scroll + menubar = !menubar + if len(interArgs) > 0 { + fmt.Println("Args:",interArgs) + } else { + fmt.Println("No Args") + fmt.Println("Border",border) + fmt.Println("Resize",resize) + fmt.Println("Translate",move) + fmt.Println("Scroll",scroll) + fmt.Println("Menubar",menubar) + fmt.Println("magn",scaling) + } + if help { + fmt.Printf("Usage of %s Version %s:\n A simple and Customizable Cheatsheet viewer.\n\n", os.Args[0], version) + + getopt.Usage() + os.Exit(0) + } hea,dat = loadfile("data.txt") - nw := newNucularWindow() + nw := newFenestraWindow() nw.Theme = theme - Wnd = nucular.NewMasterWindow(0,hea, nw.nucularWindow) + Wnd = nucular.NewMasterWindow(0,hea, nw.masterWindow) Wnd.SetStyle(nstyle.FromTheme(theme, scaling)) Wnd.Main() @@ -56,17 +101,22 @@ func loadfile(filename string) (head string,out []data){ continue } if strings.HasPrefix(line,"##") { - if title != "" { + //if title != "" { out = append(out,data{title,keys,info}) - } + //} title = line[2:] keys = nil info = nil }else{ if line != "" { - da := strings.Split(line,"--") - keys = append(keys,da[0]) - info = append(info,da[1]) + if strings.Contains(line, "--"){ + da := strings.Split(line,"--") + keys = append(keys,da[0]) + info = append(info,da[1]) + }else{ + keys = append(keys,line) + info = append(info,"") + } } } } |
