Events-cli: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 10: | Line 10: | ||
Enforces the following command line structure: | Enforces the following command line structure: | ||
<''parser''> [''[[Events-api_Concepts#Query|query]]''] [''parser-specific-top-level-arguments''] [''command'' [''command-options'']] <file1> [<file2> ...] | <''parser''> [''[[Events-api_Concepts#Query|query]]''] [''[[#Parser-specific_Top-level_Argument_Processing|parser-specific-top-level-arguments]]''] [''command'' [''command-options'']] <file1> [<file2> ...] | ||
cat <input-file> | <''parser''> [''[[Events-api_Concepts#Query|query]]''] [''command''] [''command-options''] | cat <input-file> | <''parser''> [''[[Events-api_Concepts#Query|query]]''] [''command''] [''command-options''] |
Revision as of 16:52, 28 October 2017
Internal
Overview
Command line logic for event parsers.
Enforces the following command line structure:
<parser> [query] [parser-specific-top-level-arguments] [command [command-options]] <file1> [<file2> ...]
cat <input-file> | <parser> [query] [command] [command-options]
where the commands represent events-processing procedures.
User Manual
Usage
public class Main {
public static final String APPLICATION_NAME = "some-app";
public static void main(String[] args) throws Exception {
try {
Parser parser = new SomeAppParser();
ProcedureFactory procedureFactory = new SomeAppProcedureFactory();
ApplicationSpecificBehavior asb = new ApplicationSpecificBehavior(parser, procedureFactory);
EventParserRuntime runtime = new EventParserRuntime(args, APPLICATION_NAME, asb);
if (runtime.getConfiguration().isHelp()) {
runtime.displayHelp(APPLICATION_NAME);
return;
}
runtime.run();
}
catch(UserErrorException e) {
System.err.println(e.getMessage());
}
}
}
For more details about application-specific behavior pattern see:
Parser-specific Top-level Argument Processing
The processing is delegated to applications-pacific functionality using the application-specific behavior pattern:
End-to-end Testing
File f = new File(System.getProperty("basedir"), "src/test/resources/data/something.txt");
assertTrue(f.isFile());
Parser parser = new SomeParser();
MockProcedureFactory mf = new MockProcedureFactory();
ApplicationSpecificBehavior asb = new ApplicationSpecificBehavior(parser, mf);
String[] commandLine = {
"mock-procedure",
f.getPath()
};
EventParserRuntime r = new EventParserRuntime(commandLine, "test", asb);
r.run();
Development
GitHub
Maven
<dependency> <groupId>io.novaordis.events.cli</groupId> <artifactId>events-cli</artifactId> <version>${events.cli.version}</version> </dependency>