client: don't register client flags by default

Change-Id: I73a3242f1cfd2af9a63dd53c7174843a234c5f18
This commit is contained in:
Brad Fitzpatrick 2011-10-10 17:38:18 -07:00
parent 38b30381e0
commit 453fd92fbe
5 changed files with 25 additions and 13 deletions

View File

@ -31,22 +31,25 @@ limitations under the License.
package main
import (
"camli/blobref"
"camli/client"
"flag"
"io"
"log"
"os"
"strings"
"camli/blobref"
"camli/client"
)
var flagVerbose *bool = flag.Bool("verbose", false, "be verbose")
var flagCheck *bool = flag.Bool("check", false, "just check for the existence of listed blobs; returning 0 if all our present")
var flagOutput *string = flag.String("o", "-", "Output file/directory to create. Use -f to overwrite.")
var flagVia *string = flag.String("via", "", "Fetch the blob via the given comma-separated sharerefs (dev only).")
var (
flagVerbose = flag.Bool("verbose", false, "be verbose")
flagCheck = flag.Bool("check", false, "just check for the existence of listed blobs; returning 0 if all our present")
flagOutput = flag.String("o", "-", "Output file/directory to create. Use -f to overwrite.")
flagVia = flag.String("via", "", "Fetch the blob via the given comma-separated sharerefs (dev only).")
)
func main() {
client.AddFlags()
flag.Parse()
client := client.NewOrFail()

View File

@ -49,6 +49,7 @@ func main() {
// Scans the arg list and sets up flags
debug := flag.Bool("debug", false, "print debugging messages.")
threaded := flag.Bool("threaded", true, "switch off threading; print debugging messages.")
client.AddFlags()
flag.Parse()
errorf := func(msg string, args ...interface{}) {

View File

@ -531,6 +531,7 @@ func Save() {
func main() {
defer Save()
jsonsign.AddFlags()
client.AddFlags()
flag.Parse()
if flag.NArg() == 0 {

View File

@ -27,6 +27,7 @@ var (
// TODO(rh): tame copy/paste code from cammount
func main() {
client.AddFlags()
flag.Parse()
cacheDir, err := ioutil.TempDir("", "camlicache")
if err != nil {

View File

@ -31,10 +31,16 @@ import (
"camli/osutil"
)
// These override the JSON config file ~/.camli/config "server" and
// "password" keys
var flagServer *string = flag.String("blobserver", "", "camlistore blob server")
var flagPassword *string = flag.String("password", "", "password for blob server")
// These, if set, override the JSON config file ~/.camli/config
// "server" and "password" keys.
//
// A main binary must call AddFlags to expose these.
var flagServer, flagPassword *string
func AddFlags() {
flagServer = flag.String("blobserver", "", "camlistore blob server")
flagPassword = flag.String("password", "", "password for blob server")
}
func ConfigFilePath() string {
return filepath.Join(osutil.CamliConfigDir(), "config")
@ -66,7 +72,7 @@ func cleanServer(server string) string {
}
func blobServerOrDie() string {
if *flagServer != "" {
if flagServer != nil && *flagServer != "" {
return cleanServer(*flagServer)
}
configOnce.Do(parseConfig)
@ -83,7 +89,7 @@ func blobServerOrDie() string {
}
func passwordOrDie() string {
if *flagPassword != "" {
if flagPassword != nil && *flagPassword != "" {
return *flagPassword
}
configOnce.Do(parseConfig)