Closed GoogleCodeExporter closed 9 years ago
Ok. I got it, It is mentioned nowhere that I have to add my command in the list
of commands in cli.config.
Original comment by emtiazah...@gmail.com
on 11 Apr 2012 at 11:39
Will update the doc.
Original comment by vladimir...@gmail.com
on 23 Apr 2012 at 10:38
I have added a section on updating cli.config.
Original comment by vladimir...@gmail.com
on 23 Apr 2012 at 11:03
Thanks man.
Original comment by emtiazah...@gmail.com
on 23 Apr 2012 at 6:52
I am doing some simple projects.
Same problem for me as well, I have done exactly same as mentioned in the
webpage but gives me error. Any idea ?
Also how do I get rid of the clamshell banner at the front ?
b64-cli > help
Available Commands
------------------
base_64 Prints base 64 information
exit Exits ClamShell.
help Displays help information for available commands.
sysinfo Displays current JVM runtime information.
b64-cli > base_64
Command unhandled.
No controller found to respond to [base_64].
Here is my code and config:
cat cli.config
{
"properties":{
"libDir":"./lib",
"pluginsDir":"./plugins"
},
"controllers":{
"org.clamshellcli.base64.Base64Controller":{
"enabled":"true",
"inputPattern":"\\s*(exit|base_64)\\b.*",
"expectedInputs":[]
},
"org.clamshellcli.impl.CmdController":{
"enabled":"true",
"inputPattern":"\\s*(exit|help|sysinfo|time)\\b.*",
"expectedInputs":[]
}
}
}
org.clamshellcli.api.Plugin is having:
org.clamshellcli.base64.Base64SplashScreen
org.clamshellcli.base64.Base64Prompt
org.clamshellcli.base64.Base64Controller
package org.clamshellcli.base64;
import java.util.Collections;
import java.util.Date;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
import org.clamshellcli.api.Command;
import org.clamshellcli.api.Context;
import org.clamshellcli.api.IOConsole;
public class Base64Controller implements Command {
private static final String NAMESPACE = "base64";
private static final String ACTION_NAME = "base_64";
@Override
public Object execute(Context ctx) {
IOConsole console = ctx.getIoConsole();
console.writeOutput(String.format("%n%s%n%n",new Date().toString()));
byte[] encodedBytes = Base64.encodeBase64("JavaTips.net".getBytes());
console.writeOutput("encodedBytes " + new String(encodedBytes));
byte[] decodedBytes = Base64.decodeBase64(encodedBytes);
console.writeOutput("decodedBytes " + new String(decodedBytes));
return null;
}
@Override
public Descriptor getDescriptor(){
return new Command.Descriptor() {
@Override public String getNamespace() {return NAMESPACE;}
@Override
public String getName() {
return ACTION_NAME;
}
@Override
public String getDescription() {
return "Prints base 64 information";
}
@Override
public String getUsage() {
return "Type 'base_64'";
}
@Override
public Map<String, String> getArguments() {
return Collections.emptyMap();
}
};
}
@Override
public void plug(Context plug) {
// no load-time setup needed
}
}
Original comment by kaustabh...@gmail.com
on 12 Sep 2012 at 6:43
Hi. There are couple of things you should change:
1. You are implementing the Command interface (not an InputController). You
should rename your command to Base64Command (not Base64Controller).
2. Since you are creating a Command (not an InputController) you don't need
to declare a controller in the config file. Your config should look like the
following:
{
"properties":{
"libDir":"./lib",
"pluginsDir":"./plugins"
},
"controllers":{
"org.clamshellcli.impl.CmdController":{
"enabled":"true",
"inputPattern":"\\s*(exit|help|sysinfo|time|base_64)\\b.*",
"expectedInputs":[]
}
}
}
Hope this helps.
Original comment by vladimir...@gmail.com
on 12 Sep 2012 at 1:22
@kaustabh: to remove the clamshell banner, just remove the splashscreen jar
from the plugins directory. Or see the following to see how to implement your
own SplashScreen interface -
http://code.google.com/p/clamshell-cli/source/browse/clamshell-impl-splashscreen
/src/main/java/org/clamshellcli/impl/CliSplashScreen.java
Original comment by vladimir...@gmail.com
on 12 Sep 2012 at 7:32
Many thanks :) The tips were helpful and I figured out the rest.
Original comment by kaustabh...@gmail.com
on 17 Sep 2012 at 4:27
Original issue reported on code.google.com by
emtiazah...@gmail.com
on 11 Apr 2012 at 8:33