Skip to content

Commit f4e3655

Browse files
committed
Added support for staging.
1 parent 536d576 commit f4e3655

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

Sources/segmentcli/Commands/Profile.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class ProfileSetCommand: Command {
7777
}
7878

7979
// MARK: - Global option for profile
80-
8180
let specifiedProfileKey = Key<String>("-p", "--profile", description: "Specify a profile name to use for this operation")
8281
extension Command {
8382
var specifiedProfile: String? {

Sources/segmentcli/PAPI/PAPI.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@
66
//
77

88
import Foundation
9+
import SwiftCLI
910

10-
let PAPIEndpoint: String = "https://api.segmentapis.com/"
11+
var PAPIEndpoint: String {
12+
if useStagingKey.value {
13+
return "https://api.segmentapis.build/"
14+
} else {
15+
return "https://api.segmentapis.com/"
16+
}
17+
}
1118

1219
protocol PAPISection {
1320
static var pathEntry: String { get }
@@ -53,3 +60,11 @@ class PAPI {
5360
}
5461

5562
}
63+
64+
// MARK: - Global option to support staging
65+
let useStagingKey = Flag("--staging", description: "Use Segment staging for operations")
66+
extension Command {
67+
var isStaging: Bool {
68+
return useStagingKey.value
69+
}
70+
}

Sources/segmentcli/main.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func main() {
1818
SourcesGroup()
1919
])
2020

21+
segment.globalOptions.append(useStagingKey)
2122
segment.globalOptions.append(specifiedProfileKey)
2223

2324
segment.go()

0 commit comments

Comments
 (0)