makefile in root; cli args; --help, --silent, --warnings

v5stable
Ondřej Hruška 11 years ago
parent 47e8cf419a
commit 9ca95838eb
  1. 30
      Makefile
  2. 7
      README.md
  3. 6
      src/mightypork/gamecore/core/BaseApp.java
  4. 56
      src/mightypork/rogue/Launcher.java

@ -1,14 +1,16 @@
STUB = ./stub.jar STUB = ./build/stub.jar
IN_DIR = ./in IN_DIR = ./build/in
IN = $(IN_DIR)/build.jar IN = $(IN_DIR)/build.jar
OUT_DIR = ./out OUT_DIR = ./build/out
OUT = $(OUT_DIR)/release.jar OUT = $(OUT_DIR)/release.jar
TMP_DIR = ./tmp TMP_DIR = ./build/tmp
all: $(OUT) all: build
build: $(OUT)
$(OUT): $(IN) $(STUB) $(OUT): $(IN) $(STUB)
# clean # clean
@ -31,13 +33,19 @@ $(OUT): $(IN) $(STUB)
# clean # clean
rm -rf $(TMP_DIR) rm -rf $(TMP_DIR)
run: $(OUT)
java -jar $(OUT) -w ../.rogue-save
clean: run: $(OUT)
rm -rf $(OUT) java -jar $(OUT) -w .rogue-save
debug: $(OUT)
java -jar $(OUT) -w .rogue-save --verbose
runs: $(OUT)
java -jar $(OUT) -w .rogue-save --silent
runh: $(OUT)
java -jar $(OUT) -w .rogue-save --help
deploy: $(OUT) deploy: $(OUT)
cp -f $(OUT) /home/ondra/Dokumenty/Dropbox/Public/Rogue cp -f $(OUT) /home/ondra/Dropbox/Public/Rogue

@ -37,10 +37,9 @@ Manual on [Google Drive](https://docs.google.com/document/d/1Ak9oVOnCKSqWux4Hm_-
## BUILDING FROM SOURCE ## BUILDING FROM SOURCE
1. Export a jar with the `mightypork.*` packages and the `res` folder into `./build/in/build.jar` 1. Export a jar with the `mightypork.*` packages and the `res` folder into `build/in/build.jar`
2. CD into `./build` 2. Run `make` to create a stand-alone executable jar in `build/out/release.jar`
3. Run `make` to create a stand-alone executable jar in `./build/out/release.jar` 3. Use `make run` to execute it
4. Use `make run` to execute it

@ -70,6 +70,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
private ResourceLoader resourceLoader = new AsyncResourceLoader(); private ResourceLoader resourceLoader = new AsyncResourceLoader();
private Level logLevel = Level.ALL; private Level logLevel = Level.ALL;
public boolean sigleInstance; public boolean sigleInstance;
private Level logSoutLevel;
public void setConfigFile(String filename, String comment) public void setConfigFile(String filename, String comment)
@ -136,9 +137,10 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
} }
public void setLogLevel(Level logLevel) public void setLogLevel(Level logLevel, Level soutLevel)
{ {
this.logLevel = logLevel; this.logLevel = logLevel;
this.logSoutLevel = soutLevel;
} }
} }
@ -229,7 +231,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
final LogWriter log = Log.create(opt.logFilePrefix, new File(WorkDir.getDir(opt.logDir), opt.logFilePrefix + ".log"), opt.logArchiveCount); final LogWriter log = Log.create(opt.logFilePrefix, new File(WorkDir.getDir(opt.logDir), opt.logFilePrefix + ".log"), opt.logArchiveCount);
Log.setMainLogger(log); Log.setMainLogger(log);
Log.setLevel(opt.logLevel); Log.setLevel(opt.logLevel);
Log.setSysoutLevel(opt.logLevel); Log.setSysoutLevel(opt.logSoutLevel);
// connect slickutil to the logger // connect slickutil to the logger
org.newdawn.slick.util.Log.setLogSystem(new SlickLogRedirector(log)); org.newdawn.slick.util.Log.setLogSystem(new SlickLogRedirector(log));

@ -6,7 +6,6 @@ import java.util.Arrays;
import java.util.logging.Level; import java.util.logging.Level;
import mightypork.gamecore.core.BaseApp; import mightypork.gamecore.core.BaseApp;
import mightypork.gamecore.logging.Log;
import mightypork.gamecore.util.files.OsUtils; import mightypork.gamecore.util.files.OsUtils;
@ -19,9 +18,10 @@ public class Launcher {
*/ */
public static void main(String[] args) public static void main(String[] args)
{ {
Log.f3("Arguments: " + Arrays.toString(args)); System.out.println("argv = " + Arrays.toString(args)+"\n");
boolean verbose = false; Level llSyso = Level.FINER;
Level llFile = Level.ALL;
File workdir = null; File workdir = null;
@ -37,11 +37,27 @@ public class Launcher {
lwdDir = args[i + 1]; lwdDir = args[i + 1];
i++; i++;
continue; continue;
}
} else if (arg.equals("--silent") || arg.equals("-s")) {
if (arg.equals("--verbose") || arg.equals("-v")) { llSyso = Level.OFF;
verbose = true; continue;
} else if (arg.equals("--warnings") || arg.equals("-e")) {
llSyso = Level.WARNING;
continue; continue;
} else if (arg.equals("--verbose") || arg.equals("-v")) {
llSyso = Level.ALL;
continue;
} else if (arg.equals("--help") || arg.equals("-h")) {
printHelp();
System.exit(0);
} else {
System.err.println("Unknown argument: " + arg);
printHelp();
System.exit(1);
} }
} }
@ -51,14 +67,32 @@ public class Launcher {
workdir = new File(lwdDir); workdir = new File(lwdDir);
} }
} catch (final ArrayIndexOutOfBoundsException e) { } catch (final Exception e) {
Log.e("Malformed arguments."); System.out.println("Error parsing arguments:");
e.printStackTrace();
printHelp();
System.exit(1);
} }
final BaseApp app = new RogueApp(workdir, true); final BaseApp app = new RogueApp(workdir, true);
app.opt().setLogLevel(verbose ? Level.ALL : Level.FINER); app.opt().setLogLevel(llFile, llSyso);
System.out.println("\nStarting the game...\n");
app.start(); app.start();
} }
private static void printHelp()
{
//@formatter:off
System.out.println(
"Arguments:\n" +
"\t--workdir <path>, -w <path> .... specify working directory\n" +
"\t--verbose, -v .................. print all messages\n" +
"\t--silent, -s ................... print no messages\n" +
"\t--warnings, -e ................. print only warning and error messages\n" +
"\t--help, -h ..................... show this help\n");
//@formatter:on
}
} }

Loading…
Cancel
Save