View Javadoc
1   /**************************************************************************
2    *
3    * Copyright (c) 2015-2019 Yawg project contributors.
4    *
5    **************************************************************************/
6   
7   package com.varmateo.yawg.cli;
8   
9   import java.io.InputStream;
10  import java.io.IOException;
11  import java.util.logging.LogManager;
12  
13  
14  /**
15   * Program for baking a site from a directory tree.
16   */
17  public final class Main {
18  
19  
20      private static final String DEFAULT_ARGV0 = "yawg";
21  
22      // Name of system property whose value is to be used as argv0.
23      private static final String PROP_ARGV = Main.class.getName() + ".argv0";
24  
25  
26      /**
27       * No instances of this class are to be created.
28       */
29      private Main() {
30          // Nothing to do.
31      }
32  
33  
34      /**
35       * Main program.
36       *
37       * @param args Command line arguments.
38       */
39       public static void main(final String[] args)
40               throws IOException {
41  
42           setupLogging();
43  
44           final String argv0 = System.getProperty(PROP_ARGV, DEFAULT_ARGV0);
45           final BakerCliRunOptions options = BakerCliRunOptions.builder()
46                   .argv0(argv0)
47                   .addArgs(args)
48                   .output(System.out)
49                   .build();
50           final BakerCli bakerCli = BakerCli.create();
51           final int exitStatus = bakerCli.run(options);
52  
53           System.exit(exitStatus);
54      }
55  
56  
57      private static void setupLogging()
58              throws IOException {
59  
60          try ( final InputStream input = Main.class.getResourceAsStream("/logging.properties") ) {
61              LogManager.getLogManager().readConfiguration(input);
62          }
63      }
64  
65  
66  }