12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
+ // ignore_for_file: omit_local_variable_types
16
+
15
17
import 'dart:convert' ;
16
18
import 'dart:io' ;
17
19
import 'dart:math' ;
@@ -36,34 +38,47 @@ Future<void> main(List<String> args) async {
36
38
const bucketArg = 'bucket' ;
37
39
const regionArg = 'region' ;
38
40
39
- argParser.addOption (accessKeyIdArg,
40
- abbr: 'a' , valueHelp: $awsAccessKeyId, mandatory: false );
41
- argParser.addOption (secretAccessKeyArg,
42
- abbr: 's' , valueHelp: $awsSecretAccessKey, mandatory: false );
43
- argParser.addOption (sessionTokenArg,
44
- abbr: 't' , valueHelp: $awsSessionToken, mandatory: false );
45
- argParser.addOption (
46
- bucketArg,
47
- abbr: 'b' ,
48
- help: 'The name of the bucket to create' ,
49
- valueHelp: 'BUCKET' ,
50
- mandatory: false ,
51
- );
52
- argParser.addOption (
53
- regionArg,
54
- abbr: 'r' ,
55
- help: 'The region of the bucket' ,
56
- valueHelp: 'REGION' ,
57
- mandatory: true ,
58
- );
41
+ argParser
42
+ ..addOption (
43
+ accessKeyIdArg,
44
+ abbr: 'a' ,
45
+ valueHelp: $awsAccessKeyId,
46
+ mandatory: false ,
47
+ )
48
+ ..addOption (
49
+ secretAccessKeyArg,
50
+ abbr: 's' ,
51
+ valueHelp: $awsSecretAccessKey,
52
+ mandatory: false ,
53
+ )
54
+ ..addOption (
55
+ sessionTokenArg,
56
+ abbr: 't' ,
57
+ valueHelp: $awsSessionToken,
58
+ mandatory: false ,
59
+ )
60
+ ..addOption (
61
+ bucketArg,
62
+ abbr: 'b' ,
63
+ help: 'The name of the bucket to create' ,
64
+ valueHelp: 'BUCKET' ,
65
+ mandatory: false ,
66
+ )
67
+ ..addOption (
68
+ regionArg,
69
+ abbr: 'r' ,
70
+ help: 'The region of the bucket' ,
71
+ valueHelp: 'REGION' ,
72
+ mandatory: true ,
73
+ );
59
74
60
75
final parsedArgs = argParser.parse (args);
61
- final String ? accessKeyId =
62
- Platform .environment[$awsAccessKeyId] ?? parsedArgs[accessKeyIdArg];
76
+ final String ? accessKeyId = Platform .environment[$awsAccessKeyId] ??
77
+ parsedArgs[accessKeyIdArg] as String ? ;
63
78
final String ? secretAccessKey = Platform .environment[$awsSecretAccessKey] ??
64
- parsedArgs[secretAccessKeyArg];
65
- final String ? sessionToken =
66
- Platform .environment[$awsSessionToken] ?? parsedArgs[sessionTokenArg];
79
+ parsedArgs[secretAccessKeyArg] as String ? ;
80
+ final String ? sessionToken = Platform .environment[$awsSessionToken] ??
81
+ parsedArgs[sessionTokenArg] as String ? ;
67
82
68
83
if (accessKeyId == null || secretAccessKey == null ) {
69
84
exitWithError ('No AWS credentials found' );
@@ -95,11 +110,13 @@ Future<void> main(List<String> args) async {
95
110
final ServiceConfiguration serviceConfiguration = S3ServiceConfiguration ();
96
111
97
112
// Create the bucket
98
- final List <int > createBody = utf8.encode ('''
113
+ final List <int > createBody = utf8.encode (
114
+ '''
99
115
<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
100
116
<LocationConstraint>$region </LocationConstraint>
101
117
</CreateBucketConfiguration>
102
- ''' );
118
+ ''' ,
119
+ );
103
120
final AWSHttpRequest createRequest = AWSHttpRequest .put (
104
121
Uri .https (host, '/' ),
105
122
body: createBody,
0 commit comments