gosync/settings/variables.go

78 lines
1.3 KiB
Go
Raw Normal View History

2023-09-07 15:20:19 +02:00
package settings
import (
"strconv"
"strings"
"time"
2023-09-07 15:20:19 +02:00
"velvettear/gosync/log"
)
// exported variable(s)
var Verbose bool
var Source string
var Target string
var Concurrency int
var Delay time.Duration
2023-09-07 15:20:19 +02:00
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 setDelay(delay time.Duration) {
Delay = delay
ms := Delay.Milliseconds()
derp := strconv.FormatInt(ms, 10)
log.Debug("set delay", derp)
}
2023-09-07 15:20:19 +02:00
func setPassword(password string) {
Password = password
log.Debug("set password", Password)
}
func setUser(user string) {
User = user
log.Debug("set user", User)
}