mirror of
https://github.com/rclone/rclone.git
synced 2025-08-17 17:11:37 +02:00
Restore ability for any command to show stats by adding --stats flag
Make default for `mount` command not to show stats - this can be re-enabled by adding a `--stats` parameter.
This commit is contained in:
12
cmd/cmd.go
12
cmd/cmd.go
@ -224,10 +224,22 @@ func NewFsDst(args []string) fs.Fs {
|
||||
return fdst
|
||||
}
|
||||
|
||||
// ShowStats returns true if the user added a `--stats` flag to the command line.
|
||||
//
|
||||
// This is called by Run to override the default value of the
|
||||
// showStats passed in.
|
||||
func ShowStats() bool {
|
||||
statsIntervalFlag := pflag.Lookup("stats")
|
||||
return statsIntervalFlag != nil && statsIntervalFlag.Changed
|
||||
}
|
||||
|
||||
// Run the function with stats and retries if required
|
||||
func Run(Retry bool, showStats bool, cmd *cobra.Command, f func() error) {
|
||||
var err error
|
||||
var stopStats chan struct{}
|
||||
if !showStats && ShowStats() {
|
||||
showStats = true
|
||||
}
|
||||
if showStats {
|
||||
stopStats = StartStats()
|
||||
}
|
||||
|
Reference in New Issue
Block a user