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
OUT_DIR = ./out
OUT_DIR = ./build/out
OUT = $(OUT_DIR)/release.jar
TMP_DIR = ./tmp
TMP_DIR = ./build/tmp
all: $(OUT)
all: build
build: $(OUT)
$(OUT): $(IN) $(STUB)
# clean
@ -31,13 +33,19 @@ $(OUT): $(IN) $(STUB)
# clean
rm -rf $(TMP_DIR)
run: $(OUT)
java -jar $(OUT) -w ../.rogue-save
clean:
rm -rf $(OUT)
run: $(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)
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
1. Export a jar with the `mightypork.*` packages and the `res` folder into `./build/in/build.jar`
2. CD into `./build`
3. Run `make` to create a stand-alone executable jar in `./build/out/release.jar`
4. Use `make run` to execute it
1. Export a jar with the `mightypork.*` packages and the `res` folder into `build/in/build.jar`
2. Run `make` to create a stand-alone executable jar in `build/out/release.jar`
3. Use `make run` to execute it

@ -70,6 +70,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
private ResourceLoader resourceLoader = new AsyncResourceLoader();
private Level logLevel = Level.ALL;
public boolean sigleInstance;
private Level logSoutLevel;
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.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);
Log.setMainLogger(log);
Log.setLevel(opt.logLevel);
Log.setSysoutLevel(opt.logLevel);
Log.setSysoutLevel(opt.logSoutLevel);
// connect slickutil to the logger
org.newdawn.slick.util.Log.setLogSystem(new SlickLogRedirector(log));

@ -6,7 +6,6 @@ import java.util.Arrays;
import java.util.logging.Level;
import mightypork.gamecore.core.BaseApp;
import mightypork.gamecore.logging.Log;
import mightypork.gamecore.util.files.OsUtils;
@ -19,9 +18,10 @@ public class Launcher {
*/
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;
@ -37,11 +37,27 @@ public class Launcher {
lwdDir = args[i + 1];
i++;
continue;
}
if (arg.equals("--verbose") || arg.equals("-v")) {
verbose = true;
} else if (arg.equals("--silent") || arg.equals("-s")) {
llSyso = Level.OFF;
continue;
} else if (arg.equals("--warnings") || arg.equals("-e")) {
llSyso = Level.WARNING;
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);
}
} catch (final ArrayIndexOutOfBoundsException e) {
Log.e("Malformed arguments.");
} catch (final Exception e) {
System.out.println("Error parsing arguments:");
e.printStackTrace();
printHelp();
System.exit(1);
}
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();
}
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