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

Display current repository path when using haxelib list #634

Open
wants to merge 11 commits into
base: development
Choose a base branch
from
Open
Binary file modified run.n
Binary file not shown.
5 changes: 5 additions & 0 deletions src/haxelib/api/GlobalScope.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package haxelib.api;

import haxelib.client.Cli;
import sys.FileSystem;
import sys.io.File;
import haxe.ds.GenericStack;
import haxe.io.Path;
Expand All @@ -21,6 +23,9 @@ using StringTools;
class GlobalScope extends Scope {
function new(repository:Repository) {
super(false, repository);

// While this class is "GlobalScope", there's currently not a "LocalScope" equivalent class. For now we can add this here.
isLocal = RepoManager.getPath() != RepoManager.getGlobalPath();
kLabz marked this conversation as resolved.
Show resolved Hide resolved
}

public function runScript(library:ProjectName, ?callData:CallData, ?version:Version):Void {
Expand Down
19 changes: 15 additions & 4 deletions src/haxelib/client/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -553,21 +553,32 @@ class Main {

// sort projects alphabetically
libraryInfo.sort(function(a, b) return Reflect.compare(a.name.toLowerCase(), b.name.toLowerCase()));

// we want to print in one batch, rather than one cli print for each line
var listStr = '';

if (scope.isLocal)
listStr += 'Local Haxelib Repository at: ${scope.repository.path}\n';
else
listStr += 'Global Haxelib at: ${scope.repository.path}\n';

for (library in libraryInfo) {
var line = '${library.name}:';
listStr += '${library.name}:';
for (version in library.versions)
line +=
listStr +=
if (library.devPath == null && version == library.current)
' [$version]'
else
' $version';

if (library.devPath != null)
line += ' [dev:${library.devPath}]';
listStr += ' [dev:${library.devPath}]';

listStr += "\n";

Cli.print(line);
}
Cli.print(listStr);

}

function update() {
Expand Down