all switching to "weed command [args]" usage mode

git-svn-id: https://weed-fs.googlecode.com/svn/trunk@64 282b0af5-e82d-9cf1-ede4-77906d7719d0
This commit is contained in:
chris.lu@gmail.com
2012-08-07 08:29:22 +00:00
parent 3f1136c194
commit 5e9dc0e668
5 changed files with 412 additions and 3 deletions

View File

@@ -1,8 +1,10 @@
package main
import (
"encoding/json"
"flag"
"fmt"
"net/http"
"io"
"log"
"os"
@@ -13,9 +15,16 @@ import (
"unicode/utf8"
)
var IsDebug *bool
var server *string
var port *int
var commands = []*Command{
cmdFix,
cmdMaster,
cmdUpload,
cmdVersion,
cmdVolume,
}
var exitStatus = 0
@@ -163,3 +172,16 @@ func exitIfErrors() {
exit()
}
}
func writeJson(w http.ResponseWriter, r *http.Request, obj interface{}) {
w.Header().Set("Content-Type", "application/javascript")
bytes, _ := json.Marshal(obj)
callback := r.FormValue("callback")
if callback == "" {
w.Write(bytes)
} else {
w.Write([]uint8(callback))
w.Write([]uint8("("))
fmt.Fprint(w, string(bytes))
w.Write([]uint8(")"))
}
}