diff options
author | Petter Rodhelind <petter.rodhelind@gmail.com> | 2021-03-03 14:32:30 +0100 |
---|---|---|
committer | Petter Rodhelind <petter.rodhelind@gmail.com> | 2021-03-03 14:32:30 +0100 |
commit | 1a34cf54f15f8a68550b904cc95ac1cd116b7d6c (patch) | |
tree | 2ce47ba68fc949a20d647338116e6b541bd82aa9 /poe.go | |
parent | 99c5904ce43856de9091c853f53ce5d5d05a47e5 (diff) | |
download | poe-1a34cf54f15f8a68550b904cc95ac1cd116b7d6c.tar.gz poe-1a34cf54f15f8a68550b904cc95ac1cd116b7d6c.tar.bz2 poe-1a34cf54f15f8a68550b904cc95ac1cd116b7d6c.zip |
Add CLI mode and show version as command line args.
Diffstat (limited to 'poe.go')
-rw-r--r-- | poe.go | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -10,20 +10,34 @@ import ( "github.com/prodhe/poe/ui" ) +const poeVersion = "0.0.0" + func main() { + version := flag.Bool("v", false, "prints current version of poe") + cli := flag.Bool("c", false, "prints current version of poe") + flag.Parse() - e := editor.New() + if *version { + fmt.Println(poeVersion) + os.Exit(0) + } + // new editor with loaded files + e := editor.New() e.LoadBuffers(flag.Args()) - ui := ui.NewTcell() - //ui := ui.NewCli() - ui.Init(e) + // load client user interface + cui := ui.NewTcell() + if *cli { + cui = ui.NewCli() + } + + cui.Init(e) // close ui and show stack trace on panic defer func() { - ui.Close() + cui.Close() if err := recover(); err != nil { buf := make([]byte, 1<<16) @@ -35,5 +49,5 @@ func main() { }() // This will loop and listen on chosen UI. - ui.Listen() + cui.Listen() } |