Adds a list of extensions (this.extensions) and methods to handle them. See ExtensibleClassMixin documentation for details.
Alias of Application, for use by sub-classes without needing to import ocean.util.app.Application.
Short description of the application.
Command line arguments passed to the application.
Application exit status code.
Exit cleanly from the application.
Runs the application.
Prints the message in an ExitException.
Do the actual application work.
Default application extension order.
IApplicationExtension methods dummy implementation.
Test --help can be used even when required arguments are not specified
auto stdout_dev = new MemoryDevice; auto stdout = new TextOutput(stdout_dev); auto stderr_dev = new MemoryDevice; auto stderr = new TextOutput(stderr_dev); istring usage_text = "test: usage"; istring help_text = "test: help"; auto arg = new ArgumentsExt("test-name", "test-desc", usage_text, help_text, stdout, stderr); arg.args("--required").params(1).required; auto app = new App; try { arg.preRun(app, ["./app", "--help"]); test(false, "An ExitException should have been thrown"); } catch (ExitException e) { // Status should be 0 (success) test!("==")(e.status, 0); // No errors should be printed test!("==")(stderr_dev.bufferSize, 0); // Help should be printed to stdout auto s = cast(mstring) stdout_dev.peek(); test(s.length > 0, "Stdout should have some help message but it's empty"); test(s.find(arg.args.short_desc) < s.length, "No application description found in help message:\n" ~ s); test(s.find(usage_text) < s.length, "No usage text found in help message:\n" ~ s); test(s.find(help_text) < s.length, "No help text found in help message:\n" ~ s); test(s.find("--help"[]) < s.length, "--help should be found in help message:\n" ~ s); }
Tests