-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
we all need some harlem from time to time....
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
aesh/impl/src/main/java/org/jboss/forge/aesh/commands/HarlemCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2012 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.jboss.forge.aesh.commands; | ||
|
||
import org.jboss.aesh.console.Console; | ||
import org.jboss.aesh.extensions.harlem.Harlem; | ||
import org.jboss.forge.aesh.ShellContext; | ||
import org.jboss.forge.ui.UICommand; | ||
import org.jboss.forge.ui.context.UIBuilder; | ||
import org.jboss.forge.ui.context.UIContext; | ||
import org.jboss.forge.ui.context.UIValidationContext; | ||
import org.jboss.forge.ui.metadata.UICommandMetadata; | ||
import org.jboss.forge.ui.result.Result; | ||
import org.jboss.forge.ui.result.Results; | ||
import org.jboss.forge.ui.util.Metadata; | ||
|
||
/** | ||
* @author <a href="mailto:stale.pedersen@jboss.org">Ståle W. Pedersen</a> | ||
*/ | ||
public class HarlemCommand implements UICommand { | ||
@Override | ||
public UICommandMetadata getMetadata() { | ||
return Metadata.forCommand(getClass()) | ||
.name("harlem") | ||
.description("do you want some harlem?"); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled(UIContext context) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void initializeUI(UIBuilder builder) throws Exception { | ||
} | ||
|
||
@Override | ||
public void validate(UIValidationContext validator) { | ||
} | ||
|
||
@Override | ||
public Result execute(UIContext context) throws Exception { | ||
if(context instanceof ShellContext) { | ||
Console console = ((ShellContext) context).getShell().getConsole(); | ||
Harlem harlem = new Harlem(console); | ||
harlem.attach(((ShellContext) context).getConsoleOutput()); | ||
} | ||
return Results.success(); | ||
} | ||
} |