-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathentry.swift
More file actions
57 lines (50 loc) · 1.61 KB
/
entry.swift
File metadata and controls
57 lines (50 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
/// A simple example that shows how to use the AWS SDK for Swift to
/// authenticate using Amazon Cognito.
// snippet-start:[swift.identity.cognito.imports]
import ArgumentParser
import AWSCognitoIdentity
import AWSIAM
import AWSS3
import AWSSDKIdentity
import AWSSTS
import Foundation
import SmithyIdentity
// snippet-end:[swift.identity.cognito.imports]
struct ExampleCommand: ParsableCommand {
@Option(help: "AWS Region name")
var region = "us-east-1"
static var configuration = CommandConfiguration(
commandName: "cognito-resolver",
abstract: """
Demonstrates how to use a Cognito credential identity resolver with the
AWS SDK for Swift.
""",
discussion: """
"""
)
/// Called by ``main()`` to do the actual running of the AWS
/// example.
func runAsync() async throws {
let example = try Example(region: region)
try await example.run()
}
}
/// The program's asynchronous entry point.
@main
struct Main {
/// The function that serves as the main asynchronous entry point for the
/// example. It parses the command line using the Swift Argument Parser,
/// then calls the `runAsync()` function to run the example itself.
static func main() async {
let args = Array(CommandLine.arguments.dropFirst())
do {
let command = try ExampleCommand.parse(args)
try await command.runAsync()
} catch {
ExampleCommand.exit(withError: error)
}
}
}