Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the --bench option to be used when publishing package config. #13

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions src/Illuminate/Foundation/Console/ConfigPublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(ConfigPublisher $config)
*/
public function fire()
{
$package = $this->input->getArgument('package');
$package = $this->getPackage();

if ( ! is_null($path = $this->getPath()))
{
Expand All @@ -62,6 +62,25 @@ public function fire()
$this->output->writeln('<info>Configuration published for package:</info> '.$package);
}

/**
* Get the name of the package being published.
*
* @return string
*/
protected function getPackage()
{
if ( ! is_null($package = $this->input->getArgument('package')))
{
return $package;
}
elseif ( ! is_null($bench = $this->input->getOption('bench')))
{
return $bench;
}

throw new \Exception("Package or bench must be specified.");
}

/**
* Get the specified path to the files.
*
Expand All @@ -71,10 +90,23 @@ protected function getPath()
{
$path = $this->input->getOption('path');

// First we will check for an explicitly specified path from the user. If one
// exists we will use that as the path to the config files. This allows the free
// storage of config files wherever is best for this developer's web projects.
if ( ! is_null($path))
{
return $this->laravel['path.base'].'/'.$path;
}

// If a "bench" option was specified, we will publish from a workbench as the
// source location. This is mainly just a short-cut for having to manually
// specify the full workbench path using the --path command line option.
$bench = $this->input->getOption('bench');

if ( ! is_null($bench))
{
return $this->laravel['path.base']."/workbench/{$bench}/src/config";
}
}

/**
Expand All @@ -85,7 +117,7 @@ protected function getPath()
protected function getArguments()
{
return array(
array('package', InputArgument::REQUIRED, 'The name of package being published.'),
array('package', InputArgument::OPTIONAL, 'The name of package being published.'),
);
}

Expand All @@ -97,6 +129,8 @@ protected function getArguments()
protected function getOptions()
{
return array(
array('bench', null, InputOption::VALUE_OPTIONAL, 'The name of the workbench to publish.', null),

array('path', null, InputOption::VALUE_OPTIONAL, 'The path to the configuration files.', null),
);
}
Expand Down