With option, it's kernel:create --user <username> --password <password>

Use @Argument in your case to have kernal:create <username> <password>

Regards
JB

On 09/26/2014 10:50 AM, rcbandit wrote:
I have a question about creating commands in Karaf 3.0.2

I created this simple example:

@Command(scope = "kernel", name = "create", description = "create account")
public class UsersShellCommands extends OsgiCommandSupport
{

     @Option(name = "user", aliases = { "user", "--user", "-u" }, description
= "Create user", required = false, multiValued = false)
     String user;

     @Option(name = "password", aliases = { "password", "--password", "-p" },
description = "Create user password", required = false, multiValued = false)
     String passwd;

     @Override
     protected Object doExecute() throws Exception
     {
         System.out.println("Username " + user + " password " + passwd);
         return null;
     }
}

I would like to use it this way:

kernel:create user <username> password <passwd>

But I get error

karaf@root(kernel)> create user test password passwd
Error executing command kernel:create: too many arguments specified

I successfully can run this command:

karaf@root(kernel)> create --user username --password passwd
Username username password passwd

Can you help me to find my mistake?



--
View this message in context: 
http://karaf.922171.n3.nabble.com/Execute-commands-with-arguments-in-Karaf-tp4035537.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.


--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to