Issue 9 in noop: Provide Configuration object and only Configuration object instead old-style 'RawCommandLineArguments'

4 views
Skip to first unread message

no...@googlecode.com

unread,
May 25, 2012, 2:02:48 AM5/25/12
to noop-...@googlegroups.com
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


no...@googlecode.com

unread,
May 25, 2012, 2:15:13 AM5/25/12
to noop-...@googlegroups.com

Comment #1 on 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

There is a wrong implementation of 'outFile' usage in the following snippet:
<code>
console.println(cfg.outFile.name());
</code>

Probably it should be like this:
<code>
outFileWriter.write(help);
</code>

Reply all
Reply to author
Forward
0 new messages