gosync/settings/variables.go

69 lines
1.1 KiB
Go
Raw Normal View History

2023-09-07 15:20:19 +02:00
package settings
import (
"strconv"
"strings"
"velvettear/gosync/log"
)
// exported variable(s)
var Verbose bool
var Source string
var Target string
var Concurrency int
var Password string
var User string
// exported function(s)
func TargetIsRemote() bool {
return isRemote(Target)
}
func SourceIsRemote() bool {
return isRemote(Source)
}
func SourceIsWildcard() bool {
return strings.HasSuffix(Source, "/*")
2023-09-07 15:20:19 +02:00
}
// unexported function(s)
func isRemote(target string) bool {
return strings.Contains(target, ":")
}
2023-09-07 15:20:19 +02:00
func setVerbose(verbose bool) {
Verbose = verbose
if Verbose {
log.SetLogLevel(0)
} else {
log.SetLogLevel(1)
}
log.Debug("set verbose flag", strconv.FormatBool(Verbose))
}
func setSource(source string) {
Source = source
log.Debug("set source", Source)
}
func setTarget(target string) {
Target = target
log.Debug("set target", Target)
}
func setConcurrency(concurrency int) {
Concurrency = concurrency
log.Debug("set concurrency", strconv.Itoa(Concurrency))
}
func setPassword(password string) {
Password = password
log.Debug("set password", Password)
}
func setUser(user string) {
User = user
log.Debug("set user", User)
}