Skip to content

Commit

Permalink
Add developer mode argument
Browse files Browse the repository at this point in the history
  • Loading branch information
drhaynes authored and dhardiman committed Jan 22, 2024
1 parent 5d50a6e commit 3eec3a0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/Config/Arguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct Arguments {
let configURL: URL
let additionalExtension: String?
let verbose: Bool
let developerMode: Bool
}

extension Arguments {
Expand All @@ -22,8 +23,9 @@ extension Arguments {
case configPath = "--configPath"
case additionalExtension = "--ext"
case verbose = "--verbose"
case developerMode = "--dev"

static let all: [Option] = [.scheme, .configPath, .additionalExtension, .verbose]
static let all: [Option] = [.scheme, .configPath, .additionalExtension, .verbose, .developerMode]

var usage: String {
switch self {
Expand All @@ -35,6 +37,8 @@ extension Arguments {
return "\(rawValue)\t\t(Optional) An additional extension slug to add before .swift in the output files. Useful for .gitignore"
case .verbose:
return "\(rawValue)\t\t(Optional) Should extra logging be output?"
case .developerMode:
return "\(rawValue)\t\t(Optional) Enable less strict developer mode that issues warnings on missing environment variables"
}
}
}
Expand Down Expand Up @@ -65,6 +69,7 @@ extension Arguments {
self.configURL = URL(fileURLWithPath: configPath)
self.additionalExtension = argumentPairs[.additionalExtension]
self.verbose = argumentPairs[.verbose] == "true"
self.developerMode = argumentPairs[.developerMode] == "true"
}
}

Expand Down
8 changes: 8 additions & 0 deletions Tests/ConfigTests/ArgumentsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ class ArgumentsTests: XCTestCase {
"--configPath", "/config/path"
])
expect(arguments.additionalExtension).to(beNil())
}

func testDevModeIsDisabledByDefault() throws {
let arguments = try Arguments(argumentList: [
"binary",
"--scheme", "test-scheme",
"--configPath", "/config/path"
])
expect(arguments.developerMode).to(beFalse())
}

func testItThrowsAnExceptionWhenRequiredValuesAreNotPassed() {
Expand Down
1 change: 1 addition & 0 deletions Tests/ConfigTests/ConfigGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class ConfigGeneratorTests: XCTestCase {
\(Arguments.Option.configPath.usage)
\(Arguments.Option.additionalExtension.usage)
\(Arguments.Option.verbose.usage)
\(Arguments.Option.developerMode.usage)
"""))
}

Expand Down

0 comments on commit 3eec3a0

Please sign in to comment.