diff --git a/source/app.d b/source/app.d index e9cd4c3..9670c55 100644 --- a/source/app.d +++ b/source/app.d @@ -249,6 +249,13 @@ enforce(args.length >= 2, "Missing path to package."); dub.removeLocalPackage(args[1], install_system); break; + case "list-locals": + logInfo("Locals:"); + foreach( p; dub.packageManager.getPackageIterator() ) + if( p.installLocation == InstallLocation.Local ) + logInfo(" %s %s: %s", p.name, p.ver, p.path.toNativeString()); + logInfo(""); + break; } return 0; @@ -283,6 +290,7 @@ add-local Adds a local package directory (e.g. a git repository) remove-local Removes a local package directory + list-locals Prints a list of all locals General options: --annotate Do not execute dependency installations, just print diff --git a/source/dub/dub.d b/source/dub/dub.d index da738d8..1d1b4e4 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -461,6 +461,8 @@ @property string[] configurations() const { return m_app.configurations; } + @property inout(PackageManager) packageManager() inout { return m_packageManager; } + void loadPackagefromCwd() { m_root = m_cwd; diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index 2774459..25e1495 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -73,6 +73,40 @@ return ret; } + int delegate(int delegate(ref Package)) getPackageIterator() + { + int iterator(int delegate(ref Package) del) + { + // first search project local packages + foreach( p; m_projectPackages ) + if( auto ret = del(p) ) return ret; + + // then local packages + foreach( p; m_localUserPackages ) + if( auto ret = del(p) ) return ret; + + // then local packages + foreach( p; m_localSystemPackages ) + if( auto ret = del(p) ) return ret; + + // then user installed packages + foreach( pl; m_userPackages ) + foreach( v; pl ) + if( auto ret = del(v) ) + return ret; + + // finally system-wide installed packages + foreach( pl; m_systemPackages ) + foreach( v; pl ) + if( auto ret = del(v) ) + return ret; + + return 0; + } + + return &iterator; + } + int delegate(int delegate(ref Package)) getPackageIterator(string name) { int iterator(int delegate(ref Package) del)