diff --git a/scripts/rawrsync.nu b/scripts/rawrsync.nu index 5fc3ffa..daa7351 100755 --- a/scripts/rawrsync.nu +++ b/scripts/rawrsync.nu @@ -10,6 +10,7 @@ const config_path: path = ".rawrsync.toml" def main [ select?: string # Select a configuration by name --continuous (-c) # Sync on file change + --verbose (-v) # Verbose rsync logging (use NU_LOG_LEVEL=debug to set rawrsync logging level) ] { if not ($config_path | path exists) { log critical $"Could not find configuration file in current directory \(($config_path)\)" @@ -39,20 +40,29 @@ def main [ if $continuous { # TODO: only run rsync on changed files - watch --verbose $src {|| sync $src $dest} + watch --verbose $src {|| sync --verbose=$verbose $src $dest} } else { - sync $src $dest + sync --verbose=$verbose $src $dest } } def sync [ src: path dest: record + --verbose (-v) ] { - rsync ...[ + let args = [ -zar # Compress, archive (preserve permissions etc.), recursive + (if $verbose {"-v"} else {""}) --exclude=.svn --exclude=.cvs --exclude=.DS_Store --exclude=.git --exclude=.hg --exclude=*.hprof --exclude=*.pyc - $src + --exclude=.idea --exclude=.zed + --delete + ($src ++ "/") # make sure the source directory path ends with a / $"($dest.user)@($dest.address)://($dest.path)" - ] + ] | where ($it | is-not-empty) + + log info $"Syncing to ($dest.address)" + log debug $"Sync ($src) to ($dest.path) using rsync" + log debug $"rsync ($args | str join ' ')" + rsync ...$args }