// Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
//     private MBeanServerConnection serverConnection;
//     private ObjectName objectName;
//     private final Map<String, Object> environment;
//     private Object serverURL;
//     private int exitCode = 0;
// 
//     public TJContext() {
//         environment = new LinkedHashMap<String, Object>();
//     }
// 
//     public Map<String, Object> getEnvironment() {
//         return Collections.unmodifiableMap(environment);
//     }
// 
//     public void setEnvironmentVariable(String key, Object value, boolean check) {
//         if (check) {
//             if (!environment.containsKey(key)) {
//                 throw new IllegalArgumentException("Invalid key - " + key);
//             }
//             Object old = environment.get(key);
//             if (!old.getClass().equals(value.getClass())) {
//                 value = ConvertUtils.convert(value, old.getClass());
//                 if (!old.getClass().equals(value.getClass())) {
//                     throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
//                 }
//             }
//         }
//         Object prev = environment.get(key);
//         if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
//             setChanged();
//         }
//         notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
//         environment.put(key, value);
//     }
// 
//     public MBeanServerConnection getServer() {
//         return serverConnection;
//     }
// 
//     public void setServer(MBeanServerConnection serverConnection, String url) {
//         this.serverConnection = serverConnection;
//         this.serverURL = url;
//         this.objectName = null;
//     }
// 
//     public ObjectName getObjectName() {
//         return objectName;
//     }
// 
//     public void setObjectName(ObjectName objectName) {
//         this.objectName = objectName;
//     }
// 
//     public boolean isConnected() {
//         return serverConnection != null;
//     }
// 
//     public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
//         if (serverConnection == null || objectName == null) {
//             return Collections.emptyList();
//         }
//         MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
//         return Arrays.asList(beanInfo.getAttributes());
//     }
// 
//     public boolean isBeanSelected() {
//         return objectName != null;
//     }
// 
// 
//     public Object getServerURL() {
//         return serverURL;
//     }
// 
//     public void fail(CommandAction action, int code) {
//         if (exitCode == 0) {
//             exitCode = code;
//         }
//     }
// 
//     public int getExitCode() {
//         return exitCode;
//     }
// }
// 
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
// 
//     void doAction(TJContext tjContext, Output output) throws Exception;
// 
// }
// 
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
//     private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
//     private final PrintStream out;
//     private boolean useColors = true, ansiInstalled, filterInfo;
// 
//     public Output(PrintStream out, boolean useColors) {
//         this.out = out;
//         setUseColors(useColors);
//     }
// 
//     public void setFilterInfo(boolean filterInfo) {
//         this.filterInfo = filterInfo;
//     }
// 
//     public boolean isUseColors() {
//         return useColors;
//     }
// 
// 
//     public void setUseColors(boolean useColors) {
//         this.useColors = useColors;
//         if (useColors) {
//             AnsiConsole.systemInstall();
//             ansiInstalled = true;
//         } else {
//             AnsiConsole.systemUninstall();
//             ansiInstalled = false;
//         }
//     }
// 
// 
//     public void print(String text) {
//         if (useColors) {
//             out.print(ansi().render(text));
//         } else {
//             String s = ansiRemovePattern.matcher(text).replaceAll("");
//             out.print(s);
//         }
//         out.flush();
//     }
// 
// 
//     public void println(String text) {
//         print(text);
//         out.println();
//         out.flush();
//     }
// 
// 
//     @Override
//     public void close() throws IOException {
//         if (ansiInstalled) {
//             AnsiConsole.systemUninstall();
//         }
//         out.close();
//     }
// 
//     public void outError(String text) {
//         println("@|red " + text + "|@");
//     }
// 
//     public void outInfo(String text) {
//         if (! filterInfo) {
//             println("@|cyan " + text + "|@");
//         }
//     }
// }


import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import java.util.List;
import java.util.Map;
package org.jsoftware.tjconsole.command.definition;



/**
 * Set environment variable like username or password
 *
 * @author szalik
 */
public class EnvCommandDefinition extends AbstractCommandDefinition {

    public EnvCommandDefinition() {
        super("Set environment variable like username or password", "env <variableName>=<newValue>", "env", false);
    }


    public CommandAction action(String input) {
        String[] data = input.substring(prefix.length()).trim().split("=", 2);
        if (data.length < 2) {
            return new CommandAction() {
                @Override
// Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
//     private MBeanServerConnection serverConnection;
//     private ObjectName objectName;
//     private final Map<String, Object> environment;
//     private Object serverURL;
//     private int exitCode = 0;
// 
//     public TJContext() {
//         environment = new LinkedHashMap<String, Object>();
//     }
// 
//     public Map<String, Object> getEnvironment() {
//         return Collections.unmodifiableMap(environment);
//     }
// 
//     public void setEnvironmentVariable(String key, Object value, boolean check) {
//         if (check) {
//             if (!environment.containsKey(key)) {
//                 throw new IllegalArgumentException("Invalid key - " + key);
//             }
//             Object old = environment.get(key);
//             if (!old.getClass().equals(value.getClass())) {
//                 value = ConvertUtils.convert(value, old.getClass());
//                 if (!old.getClass().equals(value.getClass())) {
//                     throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
//                 }
//             }
//         }
//         Object prev = environment.get(key);
//         if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
//             setChanged();
//         }
//         notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
//         environment.put(key, value);
//     }
// 
//     public MBeanServerConnection getServer() {
//         return serverConnection;
//     }
// 
//     public void setServer(MBeanServerConnection serverConnection, String url) {
//         this.serverConnection = serverConnection;
//         this.serverURL = url;
//         this.objectName = null;
//     }
// 
//     public ObjectName getObjectName() {
//         return objectName;
//     }
// 
//     public void setObjectName(ObjectName objectName) {
//         this.objectName = objectName;
//     }
// 
//     public boolean isConnected() {
//         return serverConnection != null;
//     }
// 
//     public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
//         if (serverConnection == null || objectName == null) {
//             return Collections.emptyList();
//         }
//         MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
//         return Arrays.asList(beanInfo.getAttributes());
//     }
// 
//     public boolean isBeanSelected() {
//         return objectName != null;
//     }
// 
// 
//     public Object getServerURL() {
//         return serverURL;
//     }
// 
//     public void fail(CommandAction action, int code) {
//         if (exitCode == 0) {
//             exitCode = code;
//         }
//     }
// 
//     public int getExitCode() {
//         return exitCode;
//     }
// }
// 
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
// 
//     void doAction(TJContext tjContext, Output output) throws Exception;
// 
// }
// 
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
//     private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
//     private final PrintStream out;
//     private boolean useColors = true, ansiInstalled, filterInfo;
// 
//     public Output(PrintStream out, boolean useColors) {
//         this.out = out;
//         setUseColors(useColors);
//     }
// 
//     public void setFilterInfo(boolean filterInfo) {
//         this.filterInfo = filterInfo;
//     }
// 
//     public boolean isUseColors() {
//         return useColors;
//     }
// 
// 
//     public void setUseColors(boolean useColors) {
//         this.useColors = useColors;
//         if (useColors) {
//             AnsiConsole.systemInstall();
//             ansiInstalled = true;
//         } else {
//             AnsiConsole.systemUninstall();
//             ansiInstalled = false;
//         }
//     }
// 
// 
//     public void print(String text) {
//         if (useColors) {
//             out.print(ansi().render(text));
//         } else {
//             String s = ansiRemovePattern.matcher(text).replaceAll("");
//             out.print(s);
//         }
//         out.flush();
//     }
// 
// 
//     public void println(String text) {
//         print(text);
//         out.println();
//         out.flush();
//     }
// 
// 
//     @Override
//     public void close() throws IOException {
//         if (ansiInstalled) {
//             AnsiConsole.systemUninstall();
//         }
//         out.close();
//     }
// 
//     public void outError(String text) {
//         println("@|red " + text + "|@");
//     }
// 
//     public void outInfo(String text) {
//         if (! filterInfo) {
//             println("@|cyan " + text + "|@");
//         }
//     }
// }


// Path: src/main/java/org/jsoftware/tjconsole/command/definition/EnvCommandDefinition.java
import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import java.util.List;
import java.util.Map;

package org.jsoftware.tjconsole.command.definition;



/**
 * Set environment variable like username or password
 *
 * @author szalik
 */
public class EnvCommandDefinition extends AbstractCommandDefinition {

    public EnvCommandDefinition() {
        super("Set environment variable like username or password", "env <variableName>=<newValue>", "env", false);
    }


    public CommandAction action(String input) {
        String[] data = input.substring(prefix.length()).trim().split("=", 2);
        if (data.length < 2) {
            return new CommandAction() {
                @Override
                public void doAction(TJContext tjContext, Output output) {