Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 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 |