archiveError function
Validates format against whether the source isDir, returning an error
message to show the user, or null when the combination is allowed.
A file may be compressed as .gz or .zip; a directory as .tar.gz or
.zip. gzip cannot bundle a directory, and .tar.gz is not offered for a
single file.
Implementation
String? archiveError(ArchiveFormat format, {required bool isDir}) {
if (isDir && format == ArchiveFormat.gz) {
return 'gzip cannot archive a directory; use --tar.gz or --zip';
}
if (!isDir && format == ArchiveFormat.tarGz) {
return 'use --gz or --zip for a single file';
}
return null;
}