mirror of https://github.com/perkeep/perkeep.git
Add --version flags to tools.
Change-Id: I1c86c3de09fb59bc20539f7d1efbd4d4710bf494
This commit is contained in:
parent
ebb6fc85c2
commit
ddcec4e92c
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
|||
all:
|
||||
go install `pkg-config --libs sqlite3 1>/dev/null 2>/dev/null && echo "--tags=with_sqlite"` ./pkg/... ./server/... ./cmd/... ./third_party/...
|
||||
go install --ldflags="-X camlistore.org/pkg/buildinfo.GitInfo "`git log --pretty=format:'%ad-%h' --abbrev-commit --date=short -1` `pkg-config --libs sqlite3 1>/dev/null 2>/dev/null && echo "--tags=with_sqlite"` ./pkg/... ./server/... ./cmd/... ./third_party/...
|
||||
|
||||
# Workaround Go bug where the $GOPATH/pkg cache doesn't know about tag changes.
|
||||
# Useful when you accidentally run "make" and then "make presubmit" doesn't work.
|
||||
|
|
|
@ -48,6 +48,7 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"camlistore.org/pkg/blobref"
|
||||
"camlistore.org/pkg/buildinfo"
|
||||
"camlistore.org/pkg/cacher"
|
||||
"camlistore.org/pkg/client"
|
||||
"camlistore.org/pkg/httputil"
|
||||
|
@ -56,6 +57,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
flagVersion = flag.Bool("version", false, "show version")
|
||||
flagVerbose = flag.Bool("verbose", false, "be verbose")
|
||||
flagHTTP = flag.Bool("verbose_http", false, "show HTTP request summaries")
|
||||
flagCheck = flag.Bool("check", false, "just check for the existence of listed blobs; returning 0 if all are present")
|
||||
|
@ -69,6 +71,11 @@ func main() {
|
|||
client.AddFlags()
|
||||
flag.Parse()
|
||||
|
||||
if *flagVersion {
|
||||
fmt.Fprintf(os.Stderr, "camget version: %s\n", buildinfo.Version())
|
||||
return
|
||||
}
|
||||
|
||||
if *flagGraph && flag.NArg() != 1 {
|
||||
log.Fatalf("The --graph option requires exactly one parameter.")
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"os"
|
||||
"sort"
|
||||
|
||||
"camlistore.org/pkg/buildinfo"
|
||||
"camlistore.org/pkg/client"
|
||||
"camlistore.org/pkg/httputil"
|
||||
"camlistore.org/pkg/jsonsign"
|
||||
|
@ -33,6 +34,7 @@ import (
|
|||
const buffered = 16 // arbitrary
|
||||
|
||||
var (
|
||||
flagVersion = flag.Bool("version", false, "show version")
|
||||
flagHelp = flag.Bool("help", false, "print usage")
|
||||
flagVerbose = flag.Bool("verbose", false, "extra debug logging")
|
||||
flagHTTP = flag.Bool("verbose_http", false, "show HTTP request summaries")
|
||||
|
@ -225,6 +227,10 @@ var (
|
|||
|
||||
// camputMain is separated from main for testing from camput
|
||||
func camputMain(args ...string) {
|
||||
if *flagVersion {
|
||||
fmt.Fprintf(stderr, "camget version: %s\n", buildinfo.Version())
|
||||
return
|
||||
}
|
||||
if *flagHelp {
|
||||
usage("")
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package buildinfo
|
||||
|
||||
var GitInfo string
|
||||
|
||||
func Version() string {
|
||||
if GitInfo != "" {
|
||||
return GitInfo
|
||||
}
|
||||
return "unknown" // TODO: show binary's date?
|
||||
}
|
|
@ -21,6 +21,7 @@ import (
|
|||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"crypto/x509/pkix"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"encoding/pem"
|
||||
"flag"
|
||||
|
@ -36,8 +37,8 @@ import (
|
|||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
"database/sql"
|
||||
|
||||
"camlistore.org/pkg/buildinfo"
|
||||
"camlistore.org/pkg/jsonsign"
|
||||
"camlistore.org/pkg/osutil"
|
||||
"camlistore.org/pkg/serverconfig"
|
||||
|
@ -70,6 +71,7 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
flagVersion = flag.Bool("version", false, "show version")
|
||||
flagConfigFile = flag.String("configfile", "",
|
||||
"Config file to use, relative to the Camlistore configuration directory root. If blank, the default is used or auto-generated.")
|
||||
listenFlag = flag.String("listen", "", "host:port to listen on, or :0 to auto-select. If blank, the value in the config will be used instead.")
|
||||
|
@ -351,6 +353,11 @@ func listenAndBaseURL(config *serverconfig.Config) (listen, baseURL string) {
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
if *flagVersion {
|
||||
fmt.Fprintf(os.Stderr, "camlistored version: %s\n", buildinfo.Version())
|
||||
return
|
||||
}
|
||||
|
||||
fileName, err := findConfigFile(*flagConfigFile)
|
||||
if err != nil {
|
||||
exitf("Error finding config file %q: %v", fileName, err)
|
||||
|
|
Loading…
Reference in New Issue