// Path: client/src/main/java/com/github/e13mort/stf/console/commands/CommandContainer.java
// public class CommandContainer {
// 
//     private Map<String, Command> commandMap = new HashMap<>();
// 
//     public CommandContainer(StfCommanderContext c) {
//         commandMap.put("devices", new DevicesCommand(c.getClient(), c.getCache(), c.getOutput()));
//         commandMap.put("connect", new ConnectCommand(c.getClient(), c.getAdbRunner(), c.getCache(), c.getLogger()));
//         commandMap.put("disconnect", new DisconnectCommand(c.getClient(), c.getLogger()));
//     }
// 
//     public Command getCommand(String operation) {
//         return commandMap.get(operation);
//     }
// 
//     public Collection<String> getAllCommands() {
//         return commandMap.keySet();
//     }
// 
//     public interface Command {
//         Completable execute();
//     }
// 
// }
// 
// Path: client/src/main/java/com/github/e13mort/stf/console/commands/HelpCommandCreator.java
// public interface HelpCommandCreator {
//     CommandContainer.Command createHelpCommand(JCommander commander);
// 
//     class HelpCommandCreatorImpl implements HelpCommandCreator {
//         @Override
//         public CommandContainer.Command createHelpCommand(JCommander commander) {
//             return new HelpCommand(commander);
//         }
//     }
// }
// 
// Path: client/src/main/java/com/github/e13mort/stf/console/commands/UnknownCommandException.java
// public class UnknownCommandException extends Exception {
//     public UnknownCommandException(String message) {
//         super(message);
//     }
// }


import com.beust.jcommander.JCommander;
import com.github.e13mort.stf.console.commands.CommandContainer;
import com.github.e13mort.stf.console.commands.HelpCommandCreator;
import com.github.e13mort.stf.console.commands.UnknownCommandException;
import io.reactivex.Completable;
package com.github.e13mort.stf.console;


public class StfCommander {
    private final CommandContainer commandContainer;
    private final CommandContainer.Command defaultCommand;
    private final ErrorHandler errorHandler;
    private String commandName;

    private StfCommander(
            String commandName,
            CommandContainer commandContainer,
            CommandContainer.Command defaultCommand,
            ErrorHandler errorHandler) {
        this.commandName = commandName;
        this.commandContainer = commandContainer;
        this.defaultCommand = defaultCommand;
        this.errorHandler = errorHandler;
    }

// Path: client/src/main/java/com/github/e13mort/stf/console/commands/CommandContainer.java
// public class CommandContainer {
// 
//     private Map<String, Command> commandMap = new HashMap<>();
// 
//     public CommandContainer(StfCommanderContext c) {
//         commandMap.put("devices", new DevicesCommand(c.getClient(), c.getCache(), c.getOutput()));
//         commandMap.put("connect", new ConnectCommand(c.getClient(), c.getAdbRunner(), c.getCache(), c.getLogger()));
//         commandMap.put("disconnect", new DisconnectCommand(c.getClient(), c.getLogger()));
//     }
// 
//     public Command getCommand(String operation) {
//         return commandMap.get(operation);
//     }
// 
//     public Collection<String> getAllCommands() {
//         return commandMap.keySet();
//     }
// 
//     public interface Command {
//         Completable execute();
//     }
// 
// }
// 
// Path: client/src/main/java/com/github/e13mort/stf/console/commands/HelpCommandCreator.java
// public interface HelpCommandCreator {
//     CommandContainer.Command createHelpCommand(JCommander commander);
// 
//     class HelpCommandCreatorImpl implements HelpCommandCreator {
//         @Override
//         public CommandContainer.Command createHelpCommand(JCommander commander) {
//             return new HelpCommand(commander);
//         }
//     }
// }
// 
// Path: client/src/main/java/com/github/e13mort/stf/console/commands/UnknownCommandException.java
// public class UnknownCommandException extends Exception {
//     public UnknownCommandException(String message) {
//         super(message);
//     }
// }


// Path: client/src/main/java/com/github/e13mort/stf/console/StfCommander.java
import com.beust.jcommander.JCommander;
import com.github.e13mort.stf.console.commands.CommandContainer;
import com.github.e13mort.stf.console.commands.HelpCommandCreator;
import com.github.e13mort.stf.console.commands.UnknownCommandException;
import io.reactivex.Completable;

package com.github.e13mort.stf.console;


public class StfCommander {
    private final CommandContainer commandContainer;
    private final CommandContainer.Command defaultCommand;
    private final ErrorHandler errorHandler;
    private String commandName;

    private StfCommander(
            String commandName,
            CommandContainer commandContainer,
            CommandContainer.Command defaultCommand,
            ErrorHandler errorHandler) {
        this.commandName = commandName;
        this.commandContainer = commandContainer;
        this.defaultCommand = defaultCommand;
        this.errorHandler = errorHandler;
    }

    static StfCommander create(StfCommanderContext context, HelpCommandCreator commandCreator, ErrorHandler errorHandler, String... args) {