Add version number, -V and --version
This commit is contained in:
parent
8fd59f2e7d
commit
a81ae3c3f9
4 changed files with 20 additions and 4 deletions
|
@ -27,6 +27,7 @@ var (
|
||||||
// Flags
|
// Flags
|
||||||
cpuprofile = pflag.StringP("cpuprofile", "", "", "Write cpu profile to file")
|
cpuprofile = pflag.StringP("cpuprofile", "", "", "Write cpu profile to file")
|
||||||
statsInterval = pflag.DurationP("stats", "", time.Minute*1, "Interval to print stats")
|
statsInterval = pflag.DurationP("stats", "", time.Minute*1, "Interval to print stats")
|
||||||
|
version = pflag.BoolP("version", "V", false, "Print the version number")
|
||||||
)
|
)
|
||||||
|
|
||||||
type Command struct {
|
type Command struct {
|
||||||
|
@ -193,13 +194,13 @@ var Commands = []Command{
|
||||||
|
|
||||||
// syntaxError prints the syntax
|
// syntaxError prints the syntax
|
||||||
func syntaxError() {
|
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...>
|
Syntax: [options] subcommand <parameters> <parameters...>
|
||||||
|
|
||||||
Subcommands:
|
Subcommands:
|
||||||
|
|
||||||
`)
|
`, Version)
|
||||||
for i := range Commands {
|
for i := range Commands {
|
||||||
cmd := &Commands[i]
|
cmd := &Commands[i]
|
||||||
fmt.Fprintf(os.Stderr, " %s %s\n", cmd.Name, cmd.ArgsHelp)
|
fmt.Fprintf(os.Stderr, " %s %s\n", cmd.Name, cmd.ArgsHelp)
|
||||||
|
@ -299,6 +300,10 @@ func StartStats() {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ParseFlags()
|
ParseFlags()
|
||||||
|
if *version {
|
||||||
|
fmt.Printf("rclone %s\n", Version)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
command, args := ParseCommand()
|
command, args := ParseCommand()
|
||||||
|
|
||||||
// Make source and destination fs
|
// Make source and destination fs
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
// Globals
|
// Globals
|
||||||
var (
|
var (
|
||||||
localName, remoteName string
|
localName, remoteName string
|
||||||
|
version = pflag.BoolP("version", "V", false, "Print the version number")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Represents an item for checking
|
// Represents an item for checking
|
||||||
|
@ -257,7 +258,7 @@ func TestRmdir(flocal, fremote fs.Fs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func syntaxError() {
|
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:
|
Syntax: [options] remote:
|
||||||
|
|
||||||
|
@ -266,7 +267,7 @@ directory under it and perform tests on it, deleting it at the end.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
`)
|
`, Version)
|
||||||
pflag.PrintDefaults()
|
pflag.PrintDefaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,6 +283,10 @@ func cleanTempDir() {
|
||||||
func main() {
|
func main() {
|
||||||
pflag.Usage = syntaxError
|
pflag.Usage = syntaxError
|
||||||
pflag.Parse()
|
pflag.Parse()
|
||||||
|
if *version {
|
||||||
|
fmt.Printf("rclonetest %s\n", Version)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
fs.LoadConfig()
|
fs.LoadConfig()
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
args := pflag.Args()
|
args := pflag.Args()
|
||||||
|
|
3
rclonetest/version.go
Normal file
3
rclonetest/version.go
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
const Version = "v0.95"
|
3
version.go
Normal file
3
version.go
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
const Version = "v0.95"
|
Loading…
Reference in a new issue