Last active
October 24, 2022 04:42
-
-
Save DavidPiper94/84914202cab51adb1a3424ef861d6be4 to your computer and use it in GitHub Desktop.
Example code for article about ArgumentParser - Validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
func validate() throws { | |
let filePathWithExtension = "\(filePath)\(fileExtension)" | |
// 2 | |
if FileManager.default.fileExists(atPath: filePathWithExtension) && force == false { | |
// 3 | |
throw ValidationError("Given file already exists. To override it, please add `--force`.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment