3## A type safe, declarative, composable and extensible command line argument parser for Java.
5I was pretty sure at some point that you can use `ArgumentParser` in places of `SimpleParser` and `ComplexParser` and it would pretty much work as intended. This is what I meant by composable.
10final ArgumentParser<SimpleParsable<Integer>, ArgumentParser<SimpleParsable<Integer>, ArgumentParser<ComplexParsable<Socket>, ArgumentParser>>> parser =
11 new ArgumentParser<>(new SimpleParsable<Integer>(IntParser.parser, n -> n > 0, "You did not provide a valid positive list half-size."),
12 new ArgumentParser<>(new SimpleParsable<Integer>(IntParser.parser, m -> m > 0, "You did not provide a valid positive integer upper-bound."),
13 new ArgumentParser<>(new ComplexParsable<>(SocketParser.parser), null)));
15Pair<String, List<String>> result = parser.parse(Arrays.asList(args));
17if (result.fst != null) {
18 System.out.println(result.fst);
22final int maxInt = parser.value.value;
23final int intCount = parser.next.value.value;
24final Socket socket = parser.next.next.value.value;
28final SimpleParsable<Integer> parser = new SimpleParsable<Integer>(IntParser.parser,
29 p -> p >= 0 && p <= 65535,
30 "Could not parse port");
32final Pair<String, List<String>> patseResult = parser.parse(new ArrayList<>(Arrays.asList(args)));
34if (patseResult.fst != null) {
35 System.out.println(patseResult.fst);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list