()
| 11 | var client *sc.ShockClient |
| 12 | |
| 13 | func main() { |
| 14 | if len(os.Args) < 2 { |
| 15 | exitError("missing command") |
| 16 | } |
| 17 | command := os.Args[1] |
| 18 | if (command == "help") || (command == "-h") || (command == "--help") { |
| 19 | exitHelp() |
| 20 | } |
| 21 | |
| 22 | flags = setFlags() |
| 23 | flags.Parse(os.Args[2:]) |
| 24 | args := flags.Args() |
| 25 | |
| 26 | host, auth := getUserInfo() |
| 27 | client = sc.NewShockClient(host, auth, debug) |
| 28 | |
| 29 | var err error |
| 30 | switch command { |
| 31 | case "info": |
| 32 | var info *sc.ShockResponseMap |
| 33 | info, err = client.ServerInfo() |
| 34 | if err == nil { |
| 35 | exitOutput(&info) |
| 36 | } |
| 37 | case "create", "update": |
| 38 | var nid string |
| 39 | if len(args) > 0 { |
| 40 | nid = args[0] |
| 41 | } |
| 42 | opts := make(map[string]string) |
| 43 | if filename != "" { |
| 44 | opts["file_name"] = filename |
| 45 | } |
| 46 | if expiration != "" { |
| 47 | opts["expiration"] = expiration |
| 48 | } |
| 49 | if (command == "update") && unexpire { |
| 50 | opts["remove_expiration"] = "true" |
| 51 | } |
| 52 | if compression != "" { |
| 53 | if !validateCV("compression", compression) { |
| 54 | exitError("invalid compress type") |
| 55 | } |
| 56 | } |
| 57 | // do one of these |
| 58 | if (part > 0) && (filepath == "") { |
| 59 | // set parts node |
| 60 | if compression != "" { |
| 61 | opts["compression"] = compression |
| 62 | } |
| 63 | opts["parts"] = strconv.Itoa(part) |
| 64 | nid, err = client.PutOrPostFile("", nid, 0, attributes, "parts", opts, nil) |
| 65 | } else if (part > 0) && (filepath != "") && (command == "update") { |
| 66 | // put part file, update only |
| 67 | nid, err = client.PutOrPostFile(filepath, nid, part, attributes, "", opts, nil) |
| 68 | } else if virtual != "" { |
| 69 | // set virtual file |
| 70 | opts["virtual_file"] = virtual |
nothing calls this directly
no test coverage detected