1
mirror of https://github.com/rclone/rclone synced 2024-12-22 13:03:02 +01:00

Add version number, -V and --version

This commit is contained in:
Nick Craig-Wood 2014-04-24 17:59:05 +01:00
parent 8fd59f2e7d
commit a81ae3c3f9
4 changed files with 20 additions and 4 deletions

View File

@ -27,6 +27,7 @@ var (
// Flags
cpuprofile = pflag.StringP("cpuprofile", "", "", "Write cpu profile to file")
statsInterval = pflag.DurationP("stats", "", time.Minute*1, "Interval to print stats")
version = pflag.BoolP("version", "V", false, "Print the version number")
)
type Command struct {
@ -193,13 +194,13 @@ var Commands = []Command{
// syntaxError prints the syntax
func syntaxError() {
fmt.Fprintf(os.Stderr, `Sync files and directories to and from local and remote object stores
fmt.Fprintf(os.Stderr, `Sync files and directories to and from local and remote object stores - %s.
Syntax: [options] subcommand <parameters> <parameters...>
Subcommands:
`)
`, Version)
for i := range Commands {
cmd := &Commands[i]
fmt.Fprintf(os.Stderr, " %s %s\n", cmd.Name, cmd.ArgsHelp)
@ -299,6 +300,10 @@ func StartStats() {
func main() {
ParseFlags()
if *version {
fmt.Printf("rclone %s\n", Version)
os.Exit(0)
}
command, args := ParseCommand()
// Make source and destination fs

View File

@ -26,6 +26,7 @@ import (
// Globals
var (
localName, remoteName string
version = pflag.BoolP("version", "V", false, "Print the version number")
)
// Represents an item for checking
@ -257,7 +258,7 @@ func TestRmdir(flocal, fremote fs.Fs) {
}
func syntaxError() {
fmt.Fprintf(os.Stderr, `Test rclone with a remote to find bugs in either.
fmt.Fprintf(os.Stderr, `Test rclone with a remote to find bugs in either - %s.
Syntax: [options] remote:
@ -266,7 +267,7 @@ directory under it and perform tests on it, deleting it at the end.
Options:
`)
`, Version)
pflag.PrintDefaults()
}
@ -282,6 +283,10 @@ func cleanTempDir() {
func main() {
pflag.Usage = syntaxError
pflag.Parse()
if *version {
fmt.Printf("rclonetest %s\n", Version)
os.Exit(0)
}
fs.LoadConfig()
rand.Seed(time.Now().UnixNano())
args := pflag.Args()

3
rclonetest/version.go Normal file
View File

@ -0,0 +1,3 @@
package main
const Version = "v0.95"

3
version.go Normal file
View File

@ -0,0 +1,3 @@
package main
const Version = "v0.95"