diff --git a/scripts/rawrsync.nu b/scripts/rawrsync.nu index 330c7ed..5fc3ffa 100755 --- a/scripts/rawrsync.nu +++ b/scripts/rawrsync.nu @@ -10,33 +10,33 @@ const config_path: path = ".rawrsync.toml" def main [ select?: string # Select a configuration by name --continuous (-c) # Sync on file change -] { +] { if not ($config_path | path exists) { log critical $"Could not find configuration file in current directory \(($config_path)\)" - return 1 + exit 1 } - + let src: path = pwd | path expand - + let config = open $config_path | transpose name data - + let dest: record = if ($config | length) == 1 { $config | get 0.data } else if ($select | is-not-empty) { let selected_entry = $config | where name == $select - + if ($selected_entry | length) < 1 { log critical $"Could not find selected configuration \"($select)\"" - return 1 + exit 1 } - + $selected_entry | get 0.data } else { $config | input list -d name "Sync to..." | get data } - + if $continuous { # TODO: only run rsync on changed files watch --verbose $src {|| sync $src $dest} @@ -56,5 +56,3 @@ def sync [ $"($dest.user)@($dest.address)://($dest.path)" ] } - -