"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
cmd: Move exit status codes to separate package
Michael Hanselmanncf19073ac950
diff --git a/cmd/cmd.go b/cmd/cmd.goindex c8bc202c5..8c42e0ceb 100644--- a/cmd/cmd.go+++ b/cmd/cmd.go@@ -37,6 +37,7 @@ import ("github.com/rclone/rclone/fs/rc/rcserver""github.com/rclone/rclone/lib/atexit""github.com/rclone/rclone/lib/buildinfo"+ "github.com/rclone/rclone/lib/exitcode""github.com/rclone/rclone/lib/random""github.com/rclone/rclone/lib/terminal""github.com/spf13/cobra"@@ -60,19 +61,6 @@ var (errorTooManyArguments = errors.New("too many arguments"))-const (- exitCodeSuccess = iota- exitCodeUsageError- exitCodeUncategorizedError- exitCodeDirNotFound- exitCodeFileNotFound- exitCodeRetryError- exitCodeNoRetryError- exitCodeFatalError- exitCodeTransferExceeded- exitCodeNoFilesTransferred-)-// ShowVersion prints the version to stdoutfunc ShowVersion() {osVersion, osKernel := buildinfo.GetOSVersion()@@ -484,31 +472,31 @@ func resolveExitCode(err error) {if err == nil {if ci.ErrorOnNoTransfer {if accounting.GlobalStats().GetTransfers() == 0 {- os.Exit(exitCodeNoFilesTransferred)+ os.Exit(exitcode.NoFilesTransferred)}}- os.Exit(exitCodeSuccess)+ os.Exit(exitcode.Success)}_, unwrapped := fserrors.Cause(err)switch {case unwrapped == fs.ErrorDirNotFound:- os.Exit(exitCodeDirNotFound)+ os.Exit(exitcode.DirNotFound)case unwrapped == fs.ErrorObjectNotFound:- os.Exit(exitCodeFileNotFound)+ os.Exit(exitcode.FileNotFound)case unwrapped == errorUncategorized:- os.Exit(exitCodeUncategorizedError)+ os.Exit(exitcode.UncategorizedError)case unwrapped == accounting.ErrorMaxTransferLimitReached:- os.Exit(exitCodeTransferExceeded)+ os.Exit(exitcode.TransferExceeded)case fserrors.ShouldRetry(err):- os.Exit(exitCodeRetryError)+ os.Exit(exitcode.RetryError)case fserrors.IsNoRetryError(err):- os.Exit(exitCodeNoRetryError)+ os.Exit(exitcode.NoRetryError)case fserrors.IsFatalError(err):- os.Exit(exitCodeFatalError)+ os.Exit(exitcode.FatalError)default:- os.Exit(exitCodeUsageError)+ os.Exit(exitcode.UsageError)}}diff --git a/lib/exitcode/exitcode.go b/lib/exitcode/exitcode.gonew file mode 100644index 000000000..7b850cdb8--- /dev/null+++ b/lib/exitcode/exitcode.go@@ -0,0 +1,25 @@+// Package exitcode exports rclone's exit status numbers.+package exitcode++const (+ // Success is returned when rclone finished without error.+ Success = iota+ // UsageError is returned when there was a syntax or usage error in the arguments.+ UsageError+ // UncategorizedError is returned for any error not categorised otherwise.+ UncategorizedError+ // DirNotFound is returned when a source or destination directory is not found.+ DirNotFound+ // FileNotFound is returned when a source or destination file is not found.+ FileNotFound+ // RetryError is returned for temporary errors during operations which may be retried.+ RetryError+ // NoRetryError is returned for errors from operations which can't/shouldn't be retried.+ NoRetryError+ // FatalError is returned for errors one or more retries won't resolve.+ FatalError+ // TransferExceeded is returned when network I/O exceeded the quota.+ TransferExceeded+ // NoFilesTransferred everything succeeded, but no transfer was made.+ NoFilesTransferred+)