Skip to content

Commit

Permalink
Implemented versions:remove
Browse files Browse the repository at this point in the history
  • Loading branch information
eFrane committed Sep 9, 2015
1 parent e0929cd commit 3e2be27
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 47 deletions.
5 changes: 2 additions & 3 deletions app/Console/Commands/ListVersionsCommand.php
Expand Up @@ -3,6 +3,7 @@
namespace App\Console\Commands;

use Illuminate\Console\Command;
use OParl\Spec\Version;
use OParl\Spec\VersionRepository;
use Symfony\Component\Console\Input\InputOption;

Expand Down Expand Up @@ -34,10 +35,8 @@ protected function getOptions()
*
* @return mixed
*/
public function handle()
public function handle(VersionRepository $versionRepository)
{
$versionRepository = app('VersionRepository');

$versions = collect();
$counts = [
'extra' => 0,
Expand Down
42 changes: 0 additions & 42 deletions app/Console/Commands/RemoveVersionCommand.php

This file was deleted.

56 changes: 56 additions & 0 deletions app/Console/Commands/RemoveVersionsCommand.php
@@ -0,0 +1,56 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use OParl\Spec\VersionRepository;

class RemoveVersionsCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'versions:remove {--all?} {--extraneous?}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Remove either all (except preserved) or extraneous spec versions.';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle(VersionRepository $versionRepository)
{
$mode = $this->argument('mode');

switch ($mode)
{
case 'all':
case 'extraneous':
$this->line("Removing {$mode} stored versions.");
$versionRepository->clean($mode);
return true;

default:
$this->line("Unknown mode: {$mode}");
return false;
}
}
}
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Expand Up @@ -20,7 +20,7 @@ class Kernel extends ConsoleKernel {
Commands\ListVersionsCommand::class,
Commands\UpdateVersionsCommand::class,
Commands\GetVersionCommand::class,
Commands\RemoveVersionCommand::class
Commands\RemoveVersionsCommand::class
];

protected function schedule(Schedule $schedule)
Expand Down
2 changes: 1 addition & 1 deletion lib/Spec/VersionRepository.php
Expand Up @@ -151,7 +151,7 @@ protected function cleanExtra()

protected function cleanAll()
{
$this->fs->directories(static::ARCHIVE_DIRECTORY . '*')->each(function ($dir) {
collect($this->fs->directories(static::ARCHIVE_DIRECTORY . '*'))->each(function ($dir) {
if (!$this->isPreserved($dir, 'dir'))
{
$this->fs->deleteDirectory($dir);
Expand Down

0 comments on commit 3e2be27

Please sign in to comment.