public function run()
{
if (empty($this->getArg('list'))) {
$updatedCredentials = false;
if (!empty($this->getArg('access-key-id'))) {
Mage::getConfig()->saveConfig('arkade_s3/general/access_key', $this->getArg('access-key-id'));
$updatedCredentials = true;
}
if (!empty($this->getArg('secret-key'))) {
Mage::getConfig()->saveConfig('arkade_s3/general/secret_key', $this->getArg('secret-key'));
$updatedCredentials = true;
}
if (!empty($this->getArg('bucket'))) {
Mage::getConfig()->saveConfig('arkade_s3/general/bucket', $this->getArg('bucket'));
$updatedCredentials = true;
}
if (!empty($this->getArg('region'))) {
Mage::getConfig()->saveConfig('arkade_s3/general/region', $this->getArg('region'));
$updatedCredentials = true;
}
if ($updatedCredentials) {
echo "You have successfully updated your S3 credentials.\n";
// Refresh the config cache
Mage::app()->getConfig()->reinit();
} else {
echo $this->usageHelp();
}
} else {
/** @var Arkade_S3_Helper_Data $helper */
$helper = Mage::helper('arkade_s3');
echo 'Here are your AWS credentials.';
if ($this->getArg('access-key-id') || $this->getArg('secret-key') || $this->getArg('bucket') || $this->getArg('region')) {
echo " [1mNo configuration setting was updated.[0m";
}
echo "\n\n";
echo sprintf("Access Key ID: %s\n", $helper->getAccessKey());
echo sprintf("Secret Access Key: %s\n", $helper->getSecretKey());
echo sprintf("Bucket: %s\n", $helper->getBucket());
echo sprintf("Region: %s\n", $helper->getRegion());
}
return $this;
}