AOEpeople/StackFormation

View on GitHub
src/AwsInspector/Command/Profile/ListCommand.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace AwsInspector\Command\Profile;

use StackFormation\Profile\Manager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ListCommand extends Command
{

    protected function configure()
    {
        $this
            ->setName('profile:list')
            ->setDescription('List all AWS profiles found in configuration');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $profileManager = new Manager();

        $rows=[];
        foreach($profileManager->listAllProfiles() as $profileName) {
            $rows[] = [$profileName];
        }

        $table = new \Symfony\Component\Console\Helper\Table($output);
        $table
            ->setHeaders(array('Profile Name'))
            ->setRows($rows)
        ;
        $table->render();
    }

}