| 44 | } |
| 45 | |
| 46 | func exitOutput(v interface{}) { |
| 47 | var b []byte |
| 48 | var e error |
| 49 | if pretty { |
| 50 | b, e = json.MarshalIndent(v, "", " ") |
| 51 | } else { |
| 52 | b, e = json.Marshal(v) |
| 53 | } |
| 54 | if e != nil { |
| 55 | exitError(e.Error()) |
| 56 | } |
| 57 | if (output == "") || (output == "-") || (output == "stdout") { |
| 58 | fmt.Println(string(b)) |
| 59 | } else { |
| 60 | b = append(b, '\n') |
| 61 | e = ioutil.WriteFile(output, b, 0644) |
| 62 | if e != nil { |
| 63 | exitError(e.Error()) |
| 64 | } |
| 65 | } |
| 66 | os.Exit(0) |
| 67 | } |
| 68 | |
| 69 | func getUserInfo() (host string, auth string) { |
| 70 | // set from env if exists |