Skip to content

Commit 770fc45

Browse files
authored
Add token-file option to 'package-registry login' (#6567) (#6593)
* Add token-file option to 'package-registry login' rdar://109372471 * No need to do .cString
1 parent 4b6abeb commit 770fc45

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/PackageRegistryTool/PackageRegistryTool+Auth.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ extension SwiftPackageRegistryTool {
8282
@Option(help: "Access token")
8383
var token: String?
8484

85+
@Option(
86+
name: .customLong("token-file"),
87+
help: "Path to the file containing access token"
88+
)
89+
var tokenFilePath: AbsolutePath?
90+
8591
@Flag(help: "Allow writing to netrc file without confirmation")
8692
var noConfirm: Bool = false
8793

@@ -144,6 +150,10 @@ extension SwiftPackageRegistryTool {
144150
if let token = self.token {
145151
// User provided token
146152
storePassword = token
153+
} else if let tokenFilePath {
154+
print("Reading access token from \(tokenFilePath).")
155+
storePassword = try localFileSystem.readFileContents(tokenFilePath)
156+
.trimmingCharacters(in: .whitespacesAndNewlines)
147157
} else if let stored = authorizationProvider.authentication(for: registryURL),
148158
stored.user == storeUsername
149159
{

0 commit comments

Comments
 (0)