Skip to content

Commit

Permalink
Merge pull request #217 from jfdenise/master
Browse files Browse the repository at this point in the history
Fix for GAL-236, CLI, Progress, wrong output for non ansi terminal
  • Loading branch information
aloubyansky authored Jan 17, 2019
2 parents ff748a4 + 866f3c2 commit 8fc66bd
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 24 deletions.
1 change: 1 addition & 0 deletions cli/src/main/java/org/jboss/galleon/cli/CliMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public static void main(String[] args) {
try {
pmSession = new PmSession(Configuration.parse(arguments.getOptions()), interactive);
CliTerminalConnection connection = new CliTerminalConnection();
pmSession.setConnection(connection.getConnection());
if (arguments.isHelp()) {
try {
CommandRuntime<? extends Command, ? extends CommandInvocation> runtime =
Expand Down
13 changes: 11 additions & 2 deletions cli/src/main/java/org/jboss/galleon/cli/PmSession.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 Red Hat, Inc. and/or its affiliates
* Copyright 2016-2019 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -37,6 +37,7 @@
import org.aesh.io.Resource;
import org.aesh.readline.AeshContext;
import org.aesh.readline.Prompt;
import org.aesh.terminal.Connection;
import org.aesh.utils.Config;
import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.RepositoryListener;
Expand Down Expand Up @@ -273,7 +274,7 @@ public void metadataDeployed(RepositoryEvent re) {
private String promptRoot;
private Path previousDir;
private boolean commandRunning;

private Connection connection;
public PmSession(Configuration config) throws Exception {
this(config, true);
}
Expand Down Expand Up @@ -669,4 +670,12 @@ public FeaturePackLocation getExposedLocation(Path installation, FeaturePackLoca
public void enableMavenTrace(boolean b) {
mavenListener.setActive(b);
}

void setConnection(Connection connection) {
this.connection = connection;
}

public boolean isAnsiSupported() {
return connection != null && connection.supportsAnsi();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 Red Hat, Inc. and/or its affiliates
* Copyright 2016-2019 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -29,7 +29,7 @@ public class BuildLayoutTracker extends CliProgressTracker<FPID> {
private final PmSession session;

public BuildLayoutTracker(PmSession session) {
super("Resolving feature-pack", "Feature-packs resolved.");
super(session, "Resolving feature-pack", "Feature-packs resolved.");
this.session = session;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 Red Hat, Inc. and/or its affiliates
* Copyright 2016-2019 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,6 +20,7 @@
import org.aesh.utils.ANSI;
import org.aesh.utils.Config;
import org.jboss.galleon.cli.PmCommandInvocation;
import org.jboss.galleon.cli.PmSession;
import org.jboss.galleon.progresstracking.ProgressCallback;
import org.jboss.galleon.progresstracking.ProgressTracker;

Expand Down Expand Up @@ -94,7 +95,7 @@ public void processing(String content) {
PmCommandInvocation invocation;
private final Printer printer;

CliProgressTracker(String msgStart, String msgComplete) {
CliProgressTracker(PmSession session, String msgStart, String msgComplete) {
this.msgStart = msgStart;
this.msgComplete = msgComplete;
if (Config.isWindows()) {
Expand All @@ -104,7 +105,11 @@ public void processing(String content) {
printer = new BasicPrinter();
}
} else {
printer = new ANSIPrinter();
if(session.isAnsiSupported()) {
printer = new ANSIPrinter();
} else {
printer = new BasicPrinter();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 Red Hat, Inc. and/or its affiliates
* Copyright 2016-2019 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,6 +16,7 @@
*/
package org.jboss.galleon.cli.tracking;

import org.jboss.galleon.cli.PmSession;
import org.jboss.galleon.progresstracking.ProgressTracker;
import org.jboss.galleon.state.ProvisionedConfig;

Expand All @@ -25,8 +26,8 @@
*/
public class ConfigsTracker extends CliProgressTracker<ProvisionedConfig> {

public ConfigsTracker() {
super("Generating configuration", "Configurations generated.");
public ConfigsTracker(PmSession session) {
super(session, "Generating configuration", "Configurations generated.");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 Red Hat, Inc. and/or its affiliates
* Copyright 2016-2019 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -29,7 +29,7 @@ public class FindTracker extends CliProgressTracker<FPID> {
private final PmSession session;

public FindTracker(PmSession session) {
super("Searching in", "Search done.");
super(session, "Searching in", "Search done.");
this.session = session;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 Red Hat, Inc. and/or its affiliates
* Copyright 2016-2019 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,6 +16,7 @@
*/
package org.jboss.galleon.cli.tracking;

import org.jboss.galleon.cli.PmSession;
import org.jboss.galleon.progresstracking.ProgressTracker;
import org.jboss.galleon.runtime.PackageRuntime;

Expand All @@ -26,8 +27,8 @@
*/
public class JBossModulesTracker extends CliProgressTracker<PackageRuntime> {

public JBossModulesTracker() {
super("Installing JBoss modules", "JBoss modules installed.");
public JBossModulesTracker(PmSession session) {
super(session, "Installing JBoss modules", "JBoss modules installed.");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 Red Hat, Inc. and/or its affiliates
* Copyright 2016-2019 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,6 +16,7 @@
*/
package org.jboss.galleon.cli.tracking;

import org.jboss.galleon.cli.PmSession;
import org.jboss.galleon.progresstracking.ProgressTracker;
import org.jboss.galleon.runtime.PackageRuntime;

Expand All @@ -25,8 +26,8 @@
*/
public class PackagesTracker extends CliProgressTracker<PackageRuntime> {

public PackagesTracker() {
super("Installing packages", "Packages installed.");
public PackagesTracker(PmSession session) {
super(session, "Installing packages", "Packages installed.");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 Red Hat, Inc. and/or its affiliates
* Copyright 2016-2019 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -68,12 +68,12 @@ private static void init(PmSession session) {
BuildLayoutTracker layout = new BuildLayoutTracker(session);
trackers.put(ProvisioningLayoutFactory.TRACK_LAYOUT_BUILD, layout);

PackagesTracker packages = new PackagesTracker();
PackagesTracker packages = new PackagesTracker(session);
trackers.put(ProvisioningLayoutFactory.TRACK_PACKAGES, packages);

trackers.put("JBMODULES", new JBossModulesTracker());
trackers.put("JBMODULES", new JBossModulesTracker(session));

ConfigsTracker configs = new ConfigsTracker();
ConfigsTracker configs = new ConfigsTracker(session);
trackers.put(ProvisioningLayoutFactory.TRACK_CONFIGS, configs);

UpdatesTracker updates = new UpdatesTracker(session);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 Red Hat, Inc. and/or its affiliates
* Copyright 2016-2019 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -29,7 +29,7 @@ public class UpdatesTracker extends CliProgressTracker<ProducerSpec> {
private final PmSession session;

public UpdatesTracker(PmSession session) {
super("Looking for update for", null);
super(session, "Looking for update for", null);
this.session = session;
}

Expand Down

0 comments on commit 8fc66bd

Please sign in to comment.