main.main   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 10
nop 0
dl 0
loc 20
rs 9.9
c 0
b 0
f 0
1
package main
2
3
import (
4
    "fmt"
5
    "os"
6
    "os/exec"
7
    "github.com/pkg/browser"
8
    "github.com/hermgerm29/qdbg-go/internal"
9
)
10
11
12
func main() {
13
14
    // Extract command to run
15
    cmd, args := internal.ParseArgs(os.Args)
16
17
    // Execute command
18
    output, err := exec.Command(cmd, args...).CombinedOutput()
19
20
    if err != nil {
21
        if len(output) == 0 {
22
            fmt.Printf("Command not found %s\n", cmd)
23
            os.Exit(1)
24
        }
25
        if browser.OpenURL(internal.GetSearchUrl(output)) != nil {
26
            fmt.Println("Unable to open brower. Is one installed?")
27
        }
28
    }
29
30
    // Flush command output
31
    fmt.Printf("%s", output)
32
}
33