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 to use studio create foo --submodule git@github.com:acme/foo.git #31

Merged
merged 2 commits into from
Sep 21, 2015
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions src/Console/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Studio\Config\Config;
use Studio\Creator\CreatorInterface;
use Studio\Creator\GitRepoCreator;
use Studio\Creator\GitSubmoduleCreator;
use Studio\Creator\SkeletonCreator;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
Expand Down Expand Up @@ -57,6 +58,12 @@ protected function configure()
'g',
InputOption::VALUE_REQUIRED,
'If set, this will download the given Git repository instead of creating a new one.'
)
->addOption(
'submodule',
'gs',
InputOption::VALUE_REQUIRED,
'If set, this will download the given Git repository (as submodule) instead of creating a new one.'
);
}

Expand Down Expand Up @@ -92,6 +99,8 @@ protected function makeCreator(InputInterface $input)

if ($input->getOption('git')) {
return new GitRepoCreator($input->getOption('git'), $path);
} elseif ($input->getOption('submodule')) {
return new GitSubmoduleCreator($input->getOption('submodule'), $path);
} else {
$creator = new SkeletonCreator($path);
$this->installParts($creator);
Expand Down
16 changes: 16 additions & 0 deletions src/Creator/GitSubmoduleCreator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Studio\Creator;

use Studio\Shell\Shell;

class GitSubmoduleCreator extends GitRepoCreator
{

protected function cloneRepository()
{
Shell::run("git submodule add $this->repo $this->path");
Shell::run("git submodule init");
}

}