]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/micro.go
Add simulation screen tests
[micro.git] / cmd / micro / micro.go
index b3a3aa49022f6923c91960f63c6d2e9789351479..7c43c4a7060abf84e15abc660e653a6b79261947 100644 (file)
@@ -45,7 +45,7 @@ func InitFlags() {
                fmt.Println("    \tCleans the configuration directory")
                fmt.Println("-config-dir dir")
                fmt.Println("    \tSpecify a custom location for the configuration directory")
-               fmt.Println("[FILE]:LINE:COL")
+               fmt.Println("[FILE]:LINE:COL (if the `parsecursor` option is enabled)")
                fmt.Println("+LINE:COL")
                fmt.Println("    \tSpecify a line and column to start the cursor at when opening a buffer")
                fmt.Println("-options")
@@ -132,7 +132,7 @@ func DoPluginFlags() {
 
 // LoadInput determines which files should be loaded into buffers
 // based on the input stored in flag.Args()
-func LoadInput() []*buffer.Buffer {
+func LoadInput(args []string) []*buffer.Buffer {
        // There are a number of ways micro should start given its input
 
        // 1. If it is given a files in flag.Args(), it should open those
@@ -147,7 +147,6 @@ func LoadInput() []*buffer.Buffer {
        var filename string
        var input []byte
        var err error
-       args := flag.Args()
        buffers := make([]*buffer.Buffer, 0, len(args))
 
        btype := buffer.BTDefault
@@ -171,7 +170,7 @@ func LoadInput() []*buffer.Buffer {
                                screen.TermMessage(err)
                                continue
                        }
-                       flagStartPos = buffer.Loc{col, line - 1}
+                       flagStartPos = buffer.Loc{col - 1, line - 1}
                } else if len(match) == 3 && match[2] == "" {
                        line, err := strconv.Atoi(match[1])
                        if err != nil {
@@ -243,7 +242,10 @@ func main() {
        if err != nil {
                screen.TermMessage(err)
        }
-       config.InitGlobalSettings()
+       err = config.InitGlobalSettings()
+       if err != nil {
+               screen.TermMessage(err)
+       }
 
        // flag options
        for k, v := range optionFlags {
@@ -259,7 +261,12 @@ func main() {
 
        DoPluginFlags()
 
-       screen.Init()
+       err = screen.Init()
+       if err != nil {
+               fmt.Println(err)
+               fmt.Println("Fatal: Micro could not initialize a Screen.")
+               os.Exit(1)
+       }
 
        defer func() {
                if err := recover(); err != nil {
@@ -288,7 +295,8 @@ func main() {
                screen.TermMessage(err)
        }
 
-       b := LoadInput()
+       args := flag.Args()
+       b := LoadInput(args)
 
        if len(b) == 0 {
                // No buffers to open