You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove the `Command` class and place the `argGetter`, `varargsGetter`
and `run` methods directly in the `MainAnnotation` interface.
Now `command` pre-processes the arguments which clearly states which
strings will be used for each argument. This simplifies the implementation
of the `MainAnnotation` methods.
The implementation of the `main` method first instantiates the annotation and then creates a `Command`.
42
-
When creating the `Command`, the arguments can be checked and preprocessed.
43
+
The implementation of the `main` method first instantiates the annotation and then call `command`.
44
+
When calling the `command`, the arguments can be checked and preprocessed.
43
45
Then it defines a series of argument getters calling `argGetter` for each parameter and `varargGetter` for the last one if it is a varargs. `argGetter` gets an optional lambda that computes the default argument.
44
46
Finally, the `run` method is called to run the application. It receives a by-name argument that contains the call the annotated method with the instantiations arguments (using the lambdas from `argGetter`/`varargGetter`).
45
47
@@ -50,42 +52,46 @@ Example of implementation of `myMain` that takes all arguments positionally. It
50
52
// Parser used to parse command line arguments
51
53
importscala.util.CommandLineParser.FromString[T]
52
54
53
-
// Result type of the annotated method is Int
54
-
classmyMainextendsMainAnnotation:
55
-
importMainAnnotation.{ ParameterInfo, Command }
55
+
// Result type of the annotated method is Int and arguments are parsed using FromString
0 commit comments