@@ -18,26 +18,30 @@ protected function configure()
18
18
{
19
19
$ this
20
20
->setName ('configure ' )
21
- ->setDescription ('Configure with Amazon Credentials ' )
22
- ->addArgument (
23
- 'key ' ,
24
- InputArgument::REQUIRED ,
25
- 'AWS Key '
21
+ ->setDescription ('Configure with Amazon Credentials. ' )
22
+ ->addOption (
23
+ '--key ' ,
24
+ '-k ' ,
25
+ InputOption::VALUE_REQUIRED ,
26
+ 'AWS Access Key ID '
26
27
)
27
- ->addArgument (
28
- 'secret ' ,
29
- InputArgument::REQUIRED ,
30
- 'AWS Secret '
28
+ ->addOption (
29
+ '--secret ' ,
30
+ '-s ' ,
31
+ InputOption::VALUE_REQUIRED ,
32
+ 'AWS Secret Access Key '
31
33
)
32
- ->addArgument (
34
+ ->addOption (
33
35
'region ' ,
34
- InputArgument::REQUIRED ,
35
- 'Default Region '
36
+ '-r ' ,
37
+ InputOption::VALUE_REQUIRED ,
38
+ 'Default AWS Region '
36
39
)
37
- ->addArgument (
40
+ ->addOption (
38
41
'bucket ' ,
39
- InputArgument::REQUIRED ,
40
- 'Default Bucket '
42
+ '-b ' ,
43
+ InputOption::VALUE_REQUIRED ,
44
+ 'Default AWS S3 Bucket '
41
45
)
42
46
->addOption (
43
47
'--force ' ,
@@ -83,28 +87,45 @@ protected function execute(InputInterface $input, OutputInterface $output)
83
87
exit ;
84
88
}
85
89
86
- $ credentials = array (
87
- 'default ' => array (
88
- 'aws_access_key_id ' => $ input ->getArgument ('key ' ),
89
- 'aws_secret_access_key ' => $ input ->getArgument ('secret ' )
90
- )
91
- );
92
- $ config = array (
93
- 'default ' => array (
94
- 'region ' => $ input ->getArgument ('region ' )
95
- )
96
- );
97
- $ magedbmconfig = array (
98
- 'default ' => array (
99
- 'bucket ' => $ input ->getArgument ('bucket ' )
100
- )
101
- );
90
+ if ($ input ->getOption ('key ' ) && $ input ->getOption ('secret ' )) {
91
+ $ credentials = array (
92
+ 'default ' => array (
93
+ 'aws_access_key_id ' => $ input ->getOption ('key ' ),
94
+ 'aws_secret_access_key ' => $ input ->getOption ('secret ' )
95
+ )
96
+ );
102
97
103
- $ writer ->writeToFile ($ this ->getAwsCredentialsPath (), $ credentials );
104
- $ writer ->writeToFile ($ this ->getAwsConfigPath (), $ config );
105
- $ writer ->writeToFile ($ this ->getAppConfigPath (), $ magedbmconfig );
98
+ $ writer ->writeToFile ($ this ->getAwsCredentialsPath (), $ credentials );
99
+ $ this ->getOutput ()->writeln ('<info>Successfully configured AWS credentials.</info> ' );
100
+ } elseif (!file_exists ($ this ->getAwsCredentialsPath ())) {
101
+ $ this ->getOutput ()->writeln ('<error>No AWS credentials were found, nor provided.</error> ' );
102
+ }
103
+
104
+ if ($ input ->getOption ('region ' )) {
105
+ $ config = array (
106
+ 'default ' => array (
107
+ 'region ' => $ input ->getOption ('region ' )
108
+ )
109
+ );
110
+
111
+ $ writer ->writeToFile ($ this ->getAwsConfigPath (), $ config );
112
+ $ this ->getOutput ()->writeln ('<info>Successfully configured AWS region config.</info> ' );
113
+ } else if (!file_exists ($ this ->getAwsConfigPath ())) {
114
+ $ this ->getOutput ()->writeln ('<error>No AWS config was found, nor provided.</error> ' );
115
+ }
116
+
117
+ if ($ input ->getOption ('bucket ' )) {
118
+ $ magedbmconfig = array (
119
+ 'default ' => array (
120
+ 'bucket ' => $ input ->getOption ('bucket ' )
121
+ )
122
+ );
106
123
107
- $ this ->getOutput ()->writeln ('<info>Successfully configured.</info> ' );
124
+ $ writer ->writeToFile ($ this ->getAppConfigPath (), $ magedbmconfig );
125
+ $ this ->getOutput ()->writeln ('<info>Successfully configured magedbm config.</info> ' );
126
+ } elseif (!file_exists ($ this ->getAppConfigPath ())) {
127
+ $ this ->getOutput ()->writeln ('<error>No MageDBM was found, nor provided.</error> ' );
128
+ }
108
129
}
109
130
110
131
/**
0 commit comments