diff --git a/resources/php_compat_info.json b/resources/php/php_compat_info.json rename from resources/php_compat_info.json rename to resources/php/php_compat_info.json diff --git a/scripts/phutil_rebuild_map.php b/scripts/library/library-map.php rename from scripts/phutil_rebuild_map.php rename to scripts/library/library-map.php --- a/scripts/phutil_rebuild_map.php +++ b/scripts/library/library-map.php @@ -1,7 +1,7 @@ #!/usr/bin/env php setTagline(pht('rebuild the library map file')); diff --git a/scripts/phutil_symbols.php b/scripts/library/library-symbols.php rename from scripts/phutil_symbols.php rename to scripts/library/library-symbols.php --- a/scripts/phutil_symbols.php +++ b/scripts/library/library-symbols.php @@ -5,12 +5,12 @@ // built-in symbol list through introspection. $builtins = phutil_symbols_get_builtins(); -require_once dirname(__FILE__).'/__init_script__.php'; +require_once dirname(dirname(__FILE__)).'/init/init-script.php'; $args = new PhutilArgumentParser($argv); $args->setTagline(pht('identify symbols in a PHP source file')); $args->setSynopsis(<<getPath($file); - $bin = dirname(__FILE__).'/../../scripts/phutil_symbols.php'; - return new ExecFuture('php %s --ugly -- %s', $bin, $absolute_file); + $root = dirname(dirname(dirname(__FILE__))); + $bin = $root.'/scripts/library/library-symbols.php'; + + return new ExecFuture('php %R --ugly -- %R', $bin, $absolute_file); } @@ -439,7 +441,7 @@ $symbol_cache = $this->loadSymbolCache(); // If the XHPAST binary is not up-to-date, build it now. Otherwise, - // `phutil_symbols.php` will attempt to build the binary and will fail + // `library-symbols.php` will attempt to build the binary and will fail // miserably because it will be trying to build the same file multiple // times in parallel. if (!PhutilXHPASTBinary::isAvailable()) { diff --git a/src/workflow/ArcanistLiberateWorkflow.php b/src/workflow/ArcanistLiberateWorkflow.php --- a/src/workflow/ArcanistLiberateWorkflow.php +++ b/src/workflow/ArcanistLiberateWorkflow.php @@ -73,51 +73,50 @@ if (count($argv) > 1) { throw new ArcanistUsageException( pht( - "Provide only one path to '%s'. The path should be a directory ". - "where you want to create or update a libphutil library.", - 'arc liberate')); - } else if (count($argv) == 0) { - $path = getcwd(); + 'Provide only one path to "arc liberate". The path should identify '. + 'a directory where you want to create or update a library.')); + } else if (!$argv) { + $init_files = id(new FileFinder(getcwd())) + ->withPath('*/__phutil_library_init__.php') + ->find(); + + if (!$init_files) { + throw new ArcanistUsageException( + pht( + 'Unable to find any libraries under the current working '. + 'directory. To create a library, provide a path.')); + } + + $paths = array(); + foreach ($init_files as $init) { + $paths[] = Filesystem::resolvePath(dirname($init)); + } } else { - $path = reset($argv); + $paths = array( + Filesystem::resolvePath(head($argv)), + ); } $is_remap = $this->getArgument('remap'); $is_verify = $this->getArgument('verify'); - $path = Filesystem::resolvePath($path); - - if (Filesystem::pathExists($path) && is_dir($path)) { - $init = id(new FileFinder($path)) - ->withPath('*/__phutil_library_init__.php') - ->find(); - } else { - $init = null; + foreach ($paths as $path) { + $this->liberatePath($path); } - if ($init) { - if (count($init) > 1) { - throw new ArcanistUsageException( - pht( - 'Specified directory contains more than one libphutil library. '. - 'Use a more specific path.')); - } - $path = Filesystem::resolvePath(dirname(reset($init)), $path); - } else { - $found = false; - foreach (Filesystem::walkToRoot($path) as $dir) { - if (Filesystem::pathExists($dir.'/__phutil_library_init__.php')) { - $path = $dir; - $found = true; - break; - } - } - if (!$found) { - echo pht("No library currently exists at that path...\n"); - $this->liberateCreateDirectory($path); - $this->liberateCreateLibrary($path); - return; - } + return 0; + } + + private function liberatePath($path) { + if (!Filesystem::pathExists($path.'/__phutil_library_init__.php')) { + echo tsprintf( + "%s\n", + pht( + 'No library currently exists at the path "%s"...', + $path)); + $this->liberateCreateDirectory($path); + $this->liberateCreateLibrary($path); + return; } $version = $this->getLibraryFormatVersion($path); @@ -161,7 +160,7 @@ } private function liberateVersion2($path) { - $bin = $this->getScriptPath('scripts/phutil_rebuild_map.php'); + $bin = $this->getScriptPath('scripts/library/library-map.php'); return phutil_passthru( 'php %s %C %s', @@ -244,7 +243,7 @@ private function getScriptPath($script) { - $root = dirname(phutil_get_library_root('phutil')); + $root = dirname(phutil_get_library_root('arcanist')); return $root.'/'.$script; }