Hi all,

relevant to the issue  https://issues.apache.org/jira/browse/KARAF-780
KARAF-780  I want to start a discussion and share my thoughts about the
wizard command:

First I'll try to make clear what the commands needs are:
- it should be always possible to execute the command in one line, (for
script automation, so the wizard should be optional) 
- it should be possible to have some optional and non-optional attributes 
- if all non-optional attributes are entered in one line the wizard will not
get started
- if some non-optional attributes are missing, the wizard will be started
-furthermore should it be possible 
- to accept more complex objects as arguments, i.e. create new instances, or
references to other classes,

what I imagine myself under the word "wizard":
a wizard is for me: to lead the user through some well defined steps, so
according to the description above: if an non-optional attribute was not
set, the user will be asked something like this:
no value defined for field "name": (default: noname): 

more in detail:

{code}
@Command(scope = "user", name = "create", description = "Create new user")
public class UserCreationCommand extends OsgiCommandSupport {

@Argument(..., optional=false )
private String id;
@Argument(..., optional=false )
private String name;
@Argument(..., optional=true )
private String age;

protected Object doExecute() throws Exception {
//do something with the arguments, i.e. create a new user instance and
persist it....
}
{/code}

a call can be:
user:create 1        // enter
you have not defined a value defined for field "name": (default: noname): 
Goofy  ///enter
sumary: .... id=1, name=Goofy, age=null ,  ok?(yes/no)

or:
user:create        //enter
you have not defined a value defined for field "id": (default:
[autogenerated]):    ///enter
you have not defined a value defined for field "name": (default: noname): 
Goofy  ///enter
sumary: .... id=1, name=Goofy, age=null ,  ok?(yes/no)

but the question is, how do we know if the "1" is the non-optional id and
not the optional age?

so, how i can imagine how this can be implemented:
in the class DefaultActionPreparator in the method: 
public boolean prepare(Action action, CommandSession session, List params) 
are the attributes checked, so my idea is, to save those attributes which
are not set, but not-optional somewhere in the action class, and before the
method:
protected Object doExecute()  will be executed an other method like:
validateInput() will be called, 
here it should be possible to accept some user input from the console to
change and extend the attributes.

so, i hope it is a bit more clear what i was thinking about the "wizard",
what do you think about my thoughts?

kind regards 
Philipp

--
View this message in context: 
http://karaf.922171.n3.nabble.com/Extend-the-karaf-commands-by-a-wizard-tp3223630p3223630.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Reply via email to