-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (46 loc) · 1006 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Bare Minimum.
//
// Minimalistic text editor.
package main
import (
"flag"
"fmt"
"github.com/gdamore/tcell"
"io/ioutil"
"log"
"os"
"os/user"
"time"
)
func main() {
user, err := user.Current()
if err != nil {
fmt.Fprintf(os.Stderr, "error getting current user %v", err)
os.Exit(-1)
}
username := user.Username
date := time.Now().Format("2006-01-02_15-04-05")
prefix := fmt.Sprintf("bm_%s_%s_", username, date)
logfile, err := ioutil.TempFile("", prefix)
if err != nil {
fmt.Fprintf(os.Stderr, "error opening log file %v", err)
os.Exit(-1)
}
defer func() {
err = logfile.Close()
if err != nil {
fmt.Fprintf(os.Stderr, "error closing log file %v", err)
}
}()
log.SetOutput(logfile)
defer log.SetOutput(os.Stderr)
flag.Parse()
paths := []string{}
for _, path := range flag.Args() {
paths = append(paths, path)
}
screenCreate := func() (tcell.Screen, error) { return tcell.NewScreen() }
editor := New(screenCreate, paths)
editor.Start()
editor.Wait()
}