Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9d5d88a

Browse files
committed
Add dry-run validation to argument checks
Updated ValidateArguments to support an isDryRun flag, ensuring --dry-run is present when required. Adjusted Estimate to use the new parameter and refactored argument checks to use DefaultRsyncParameters constants for improved maintainability.
1 parent58a39bc commit9d5d88a

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

‎RsyncUI/Model/Execution/EstimateExecute/Estimate.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ final class Estimate {
4949
guard config.task!=SharedReference.shared.haltedelse{return}
5050
ifSharedReference.shared.validatearguments{
5151
do{
52-
tryValidateArguments().validate(config: config, arguments: arguments)
52+
tryValidateArguments().validate(config: config, arguments: arguments, isDryRun:true)
5353
}catchlet err{
5454
leterror= err
5555
SharedReference.shared.errorobject?.alert(error: error)

‎RsyncUI/Model/Utils/ValidateArguments.swift‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
//
55
// Created by Thomas Evensen on 16/12/2025.
66
//
7+
// swiftlint:disable cyclomatic_complexity
78

89
import Foundation
10+
import RsyncArguments
911

1012
enumRemoteOrLocal{
1113
case remote
@@ -17,6 +19,7 @@ enum InvalidArguments: LocalizedError {
1719
case archive
1820
case delete
1921
case nodelete
22+
case dryrun
2023

2124
varerrorDescription:String?{
2225
switchself{
@@ -28,44 +31,53 @@ enum InvalidArguments: LocalizedError {
2831
"argument --delete is MISSING"
2932
case.nodelete:
3033
"argument --delete is INCLUDED"
34+
case.dryrun:
35+
"argument --dry-run is MISSING"
3136
}
3237
}
3338
}
3439

3540
structValidateArguments{
36-
func validate(config:SynchronizeConfiguration, arguments:[String])throws{
41+
func validate(config:SynchronizeConfiguration, arguments:[String], isDryRun:Bool=false)throws{
3742
letremoteOrLocal:RemoteOrLocal= config.offsiteServer.isEmpty?.local:.remote
3843

3944
switch remoteOrLocal{
4045
case.remote:
41-
guard arguments.contains("--compress")else{
46+
guard arguments.contains(DefaultRsyncParameters.compressionEnabled.rawValue)else{
4247
throwInvalidArguments.compress
4348
}
4449

45-
guard arguments.contains("--archive")else{
50+
guard arguments.contains(DefaultRsyncParameters.archiveMode.rawValue)else{
4651
throwInvalidArguments.archive
4752
}
4853

4954
case.local:
50-
guard arguments.contains("--compress")==falseelse{
55+
guard arguments.contains(DefaultRsyncParameters.compressionEnabled.rawValue)==falseelse{
5156
throwInvalidArguments.compress
5257
}
5358

54-
guard arguments.contains("--archive")else{
59+
guard arguments.contains(DefaultRsyncParameters.archiveMode.rawValue)else{
5560
throwInvalidArguments.archive
5661
}
5762
}
5863

5964
if config.parameter4==nil{
60-
guard arguments.contains("--delete")==falseelse{
65+
guard arguments.contains(DefaultRsyncParameters.deleteExtraneous.rawValue)==falseelse{
6166
throwInvalidArguments.nodelete
6267
}
6368
}else{
64-
guard arguments.contains("--delete")else{
69+
guard arguments.contains(DefaultRsyncParameters.deleteExtraneous.rawValue)else{
6570
throwInvalidArguments.delete
6671
}
6772
}
6873

74+
if isDryRun{
75+
guard arguments.contains(DefaultRsyncParameters.dryRunMode.rawValue)else{
76+
throwInvalidArguments.dryrun
77+
}
78+
}
79+
6980
// Validation passed
7081
}
7182
}
83+
// swiftlint:enable cyclomatic_complexity

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp