Skip to content

Commit

Permalink
Interaction on alias when 2nd arg is existing…
Browse files Browse the repository at this point in the history
…alias. Just asks if we want to alias the new alias to that package as well. Useful when you want to add a few similar aliases to a single package in case of mistyping.
  • Loading branch information
geekish committed Jan 15, 2017
1 parent 6f2b478 commit eb931ef
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to `geekish/crap` will be documented in this file and follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## 1.0.0-beta.4 - TBD

### Changed

- Interaction on `alias` command when the second argument is an existing alias.

## 1.0.0-beta.3 - 2017-01-08

### Added
Expand Down
16 changes: 16 additions & 0 deletions src/Command/AliasCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@ protected function interact(InputInterface $input, OutputInterface $output)
$input->setArgument("alias", $args[2]);
$input->setArgument("package", $args[1]);
}
} elseif ($this->helper->validateAlias($args[1]) && $this->helper->hasAlias($args[2])) {
$output->writeln("<info>You provided an existing alias instead of a package.</info>");

$existing = $this->helper->getAlias($args[2]);

$message = sprintf(
"<question>Do you want to alias `%s` to `%s`?</question> (y/n) ",
$args[1],
$existing
);

$question = new ConfirmationQuestion($message, false);

if ($helper->ask($input, $output, $question)) {
$input->setArgument("package", $existing);
}
}
}
}

0 comments on commit eb931ef

Please sign in to comment.