digat / cliche

Automatically exported from code.google.com/p/cliche
MIT License
0 stars 0 forks source link

Exit current sub shell after command #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to be able to interrupt the sub command loop at the end of a 
commend.

Currently I do this like this:

public class ExitSettings extends Settings {

    public static final Settings INSTANCE = new ExitSettings();

    public ExitSettings() {
        super(ExitCommandInput.INSTANCE, SilentOutput.INSTANCE, null, Boolean.FALSE);
    }

}

public class SilentOutput implements Output {

    public static final Output INSTANCE = new SilentOutput();

    @Override
    public void outputHeader(String paramString) {
    }

    @Override
    public void outputException(String paramString, TokenException paramTokenException) {
    }

    @Override
    public void outputException(Throwable paramThrowable) {
    }

    @Override
    public void output(Object paramObject, OutputConversionEngine paramOutputConversionEngine) {
    }
}

public class ExitCommandInput implements Input {

    public static final Input INSTANCE = new ExitCommandInput();

    @Override
    public String readCommand(List<String> paramList) {
        return "exit";
    }

}

theShell.setSettings(ExitSettings.INSTANCE);

with theShell obtained from ShellDependent

would be much nicer to have something like pushSubShell and popSubShell

Original issue reported on code.google.com by william....@gmail.com on 9 Jul 2014 at 1:24