Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 9 by alexander.box: Provide Configuration object and only
Configuration object instead old-style 'RawCommandLineArguments'
http://code.google.com/p/noop/issues/detail?id=9
Old-style Command Line's arguments like in the following code snippet are
not truly Object-oriented and type-safe code.
class CommandLineApp(RawCommandLineArguments args, Console console)
implements Application {
Int main() {
console.println(args);
}
}
The right path is using some sort of a Configuration object. It's could be
a User's custom class or a per-defined interface. The new, truly
Object-oriented and type-safe code would be like this:
@CommandLineConfiguration
class MyAppConfiguration {
@Option (shortName = "h", description = "print help to the out file")
Boolean help;
@Argument(isReuired = true, description = "a file to print out")
File outFile;
}
class CommandLineApp(MyAppConfiguration cfg, Console console) implements
Application {
Int main() {
if (cfg.help) {
console.println(
cfg.outFile.name());
}
}
}
You may also take a look on the related implementation for Java:
[
http://code.google.com/p/meta-cli/]
Please let me know that you are interested and will implement it