On 5/4/10 2:33, Guillaume Nodet wrote:
A few things that would be missing imho to make that interesting:
   * parameters annotation to mark parameters as optional or multi-valued

Currently, flags are always optional, whereas options are only optional if a default value is specified. We haven't given any thought to multi-valued, but I agree that it is worth thinking about.

   * flag and option could be merged (they are the same, maybe use an enum
value on the annotation to differentiate them and maybe have a smart default
value based on the fact that the annotated parameter is a boolean or not)

Yeah, we talked about this. Peter liked them separate. It doesn't matter to me.

   * option should support a list of value
   * options should have multiple names (annotations support String[] quite
well)

Quite possibly.

   * if we want to add some help information, we need an annotation on the
method

Agreed. We also need to have a description on the flags/options.

   * we have a nice coercion mechanism defined in blueprint (handling
generics, collections and such), we should  reuse it (without having a
dependency to blueprint)

That can certainly be considered.

At this point, I am just trying to get something to work. I had originally tried to use the approach used in Karaf to make commands, but it didn't feel completely right to me. I talked with Peter and he said his vision was that people wouldn't implement commands as Gogo Functions, but just as methods on an object. So, I then started to think about how to refactor the approach using methods, but realized it would need to have some help from the Gogo runtime to make it work. So, that's what this experiment is about.

There probably will be some balancing act between making it usable for building command-line commands vs keeping it general purpose and UI independent. We'll see as we go.

-> richard

On Mon, May 3, 2010 at 23:25, Richard S. Hall<he...@ungoverned.org>  wrote:

On 5/3/10 16:56, Guillaume Nodet wrote:

On Mon, May 3, 2010 at 21:17, Richard S. Hall<he...@ungoverned.org>
  wrote:



On 5/3/10 14:51, Guillaume Nodet wrote:



What are those annotations suppose to actually provide ?  It seems all
they
can do is provide some basic help to the user, but does not really help
the
user writing complex commands and dealing with complex arguments.

Have a look at an existing example:



http://svn.apache.org/repos/asf/felix/trunk/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/GrepAction.java

I think those annotations would not provide the slightest help in
analyzing
such a command line.




I don't think there will ever be a single solution that can help everyone
implement any possible command. If people need to do something that is
super
complex, then they can always fall back to parsing their own arguments.



I can agree to that, but then I don't see why it has to be in the proposed
spec.  Having it as a separate module might be a better approach then.


The issue is you cannot easily do what we are trying to achieve in a
separate module since it is modifying how the runtime coerces arguments when
invoking methods. There is no place to hook into this externally. However, I
agree that it could be just an implementation-specific feature of the Gogo
runtime.

I actually talked with Peter specifically about this and he felt the
feature might be worthwhile for the spec, which is why he committed it
there, but nothing is set in stone at this point.

->  richard




At this point, we're just messing around with allowing optional method
parameters and out of order specification of arguments.

->   richard


  On Mon, May 3, 2010 at 19:01,<pkri...@apache.org>    wrote:





Author: pkriens
Date: Mon May  3 17:01:53 2010
New Revision: 940514

URL: http://svn.apache.org/viewvc?rev=940514&view=rev
Log:
Annotations for parameters

Added:



  felix/trunk/gogo/runtime/src/main/java/org/osgi/service/command/Flag.java



  felix/trunk/gogo/runtime/src/main/java/org/osgi/service/command/Option.java

Added:

felix/trunk/gogo/runtime/src/main/java/org/osgi/service/command/Flag.java
URL:


http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/osgi/service/command/Flag.java?rev=940514&view=auto



==============================================================================
---

felix/trunk/gogo/runtime/src/main/java/org/osgi/service/command/Flag.java
(added)
+++

felix/trunk/gogo/runtime/src/main/java/org/osgi/service/command/Flag.java
Mon May  3 17:01:53 2010
@@ -0,0 +1,6 @@
+package org.osgi.service.command;
+
+public @interface Flag {
+       String name();
+       String help() default "no help";
+}

Added:


felix/trunk/gogo/runtime/src/main/java/org/osgi/service/command/Option.java
URL:


http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/osgi/service/command/Option.java?rev=940514&view=auto



==============================================================================
---


felix/trunk/gogo/runtime/src/main/java/org/osgi/service/command/Option.java
(added)
+++


felix/trunk/gogo/runtime/src/main/java/org/osgi/service/command/Option.java
Mon May  3 17:01:53 2010
@@ -0,0 +1,6 @@
+package org.osgi.service.command;
+
+public @interface Option {
+       String name();
+       String dflt();
+}














Reply via email to