Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistLiberateWorkflow.php
| Show All 27 Lines | return array( | ||||
| $this->newWorkflowArgument('clean') | $this->newWorkflowArgument('clean') | ||||
| ->setHelp( | ->setHelp( | ||||
| pht('Perform a clean rebuild, ignoring caches. Thorough, but slow.')), | pht('Perform a clean rebuild, ignoring caches. Thorough, but slow.')), | ||||
| $this->newWorkflowArgument('argv') | $this->newWorkflowArgument('argv') | ||||
| ->setWildcard(true), | ->setWildcard(true), | ||||
| ); | ); | ||||
| } | } | ||||
| protected function newPrompts() { | |||||
| return array( | |||||
| $this->newPrompt('arc.liberate.create') | |||||
| ->setDescription( | |||||
| pht( | |||||
| 'Confirms creation of a new library.')), | |||||
| ); | |||||
| } | |||||
| public function runWorkflow() { | public function runWorkflow() { | ||||
| $log = $this->getLogEngine(); | $log = $this->getLogEngine(); | ||||
| $argv = $this->getArgument('argv'); | $argv = $this->getArgument('argv'); | ||||
| if (count($argv) > 1) { | if (count($argv) > 1) { | ||||
| throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
| pht( | pht( | ||||
| 'Provide only one path to "arc liberate". The path should identify '. | 'Provide only one path to "arc liberate". The path should identify '. | ||||
| ▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | if (Filesystem::pathExists($path)) { | ||||
| if (!is_dir($path)) { | if (!is_dir($path)) { | ||||
| throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
| pht( | pht( | ||||
| 'Provide a directory to create or update a libphutil library in.')); | 'Provide a directory to create or update a libphutil library in.')); | ||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| echo pht("The directory '%s' does not exist.", $path); | echo tsprintf( | ||||
| if (!phutil_console_confirm(pht('Do you want to create it?'))) { | "%!\n%W\n", | ||||
| throw new ArcanistUsageException(pht('Cancelled.')); | pht('NEW LIBRARY'), | ||||
| } | pht( | ||||
| 'The directory "%s" does not exist. Do you want to create it?', | |||||
| $path)); | |||||
| $query = pht('Create new library?'); | |||||
| $this->getPrompt('arc.liberate.create') | |||||
| ->setQuery($query) | |||||
| ->execute(); | |||||
| execx('mkdir -p %R', $path); | execx('mkdir -p %R', $path); | ||||
| } | } | ||||
| private function liberateCreateLibrary($path) { | private function liberateCreateLibrary($path) { | ||||
| $init_path = $path.'/__phutil_library_init__.php'; | $init_path = $path.'/__phutil_library_init__.php'; | ||||
| if (Filesystem::pathExists($init_path)) { | if (Filesystem::pathExists($init_path)) { | ||||
| return; | return; | ||||
| Show All 38 Lines | |||||