View Javadoc
1   /**************************************************************************
2    *
3    * Copyright (c) 2015-2020 Yawg project contributors.
4    *
5    **************************************************************************/
6   
7   package com.varmateo.yawg.cli;
8   
9   import io.vavr.collection.HashSet;
10  import io.vavr.collection.Set;
11  import io.vavr.control.Try;
12  
13  
14  /**
15   * Represents the set of supported command line options.
16   */
17  final class BakerCliParameters {
18  
19  
20      public static final CliParameter HELP = CliParameter.builder()
21              .longName("help")
22              .description("show this help text and exit")
23              .shortName("h")
24              .build();
25  
26      public static final CliParameter PAGE_VAR = CliParameter.builder()
27              .longName("page-var")
28              .argName("NAME=VALUE")
29              .description("additional page variable")
30              .build();
31  
32      public static final CliParameter SOURCE_DIR = CliParameter.builder()
33              .longName("source")
34              .argName("PATH")
35              .description("path of source directory")
36              .build();
37  
38      public static final CliParameter TARGET_DIR = CliParameter.builder()
39              .longName("target")
40              .argName("PATH")
41              .description("path of target directory")
42              .build();
43  
44      public static final CliParameter TEMPLATES_DIR = CliParameter.builder()
45              .longName("templates")
46              .argName("PATH")
47              .description("path of templates directory")
48              .build();
49  
50      public static final CliParameter VERBOSE = CliParameter.builder()
51              .longName("verbose")
52              .description("show abundant logging")
53              .build();
54  
55      public static final CliParameter VERSION = CliParameter.builder()
56              .shortName("v")
57              .longName("version")
58              .description("show version and exit")
59              .build();
60  
61  
62      /**
63       *
64       */
65      private static final Set<CliParameter> ALL_OPTIONS = HashSet.of(
66              HELP,
67              PAGE_VAR,
68              SOURCE_DIR,
69              TARGET_DIR,
70              TEMPLATES_DIR,
71              VERBOSE,
72              VERSION);
73  
74  
75      /**
76       * No instances of this class are to be created.
77       */
78      private BakerCliParameters() {
79          // Nothin to do.
80      }
81  
82  
83      /**
84       *
85       */
86      public static Set<CliParameter> options() {
87  
88          return ALL_OPTIONS;
89      }
90  
91  
92      /**
93       *
94       */
95      public static Try<CliParameterSet> parse(final String[] args) {
96  
97          return Try.of(() -> CliParameterSet.parse(ALL_OPTIONS, args));
98      }
99  
100 }