From 1a34cf54f15f8a68550b904cc95ac1cd116b7d6c Mon Sep 17 00:00:00 2001 From: Petter Rodhelind Date: Wed, 3 Mar 2021 14:32:30 +0100 Subject: Add CLI mode and show version as command line args. --- poe.go | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/poe.go b/poe.go index e7fff73..2a869cf 100644 --- a/poe.go +++ b/poe.go @@ -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() } -- cgit v1.2.3