cli args handling WIP
This commit is contained in:
parent
20e31468b3
commit
e7e0111f48
|
@ -9,7 +9,7 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="cf74c012-cc69-4732-ac79-9ddfcbf803ee" name="Changes" comment="brb, eating">
|
||||
<list default="true" id="cf74c012-cc69-4732-ac79-9ddfcbf803ee" name="Changes" comment="back from taco hell">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/net/screwgravity/vitality4j/standalone.java" beforeDir="false" afterPath="$PROJECT_DIR$/net/screwgravity/vitality4j/standalone.java" afterDir="false" />
|
||||
</list>
|
||||
|
@ -99,7 +99,15 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1723514215355</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="5" />
|
||||
<task id="LOCAL-00005" summary="back from taco hell">
|
||||
<option name="closed" value="true" />
|
||||
<created>1723520355301</created>
|
||||
<option name="number" value="00005" />
|
||||
<option name="presentableId" value="LOCAL-00005" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1723520355301</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="6" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
|
@ -108,6 +116,7 @@
|
|||
<MESSAGE value="initial structuring" />
|
||||
<MESSAGE value="rebase; move to package, prepare header read io" />
|
||||
<MESSAGE value="brb, eating" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="brb, eating" />
|
||||
<MESSAGE value="back from taco hell" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="back from taco hell" />
|
||||
</component>
|
||||
</project>
|
|
@ -13,6 +13,7 @@ public class standalone {
|
|||
static String operation = "";
|
||||
static String targetPath; // psarc file
|
||||
static String sourcePath; // folder contents to import when using -c, list of files to export when using -x
|
||||
static boolean overwrite = false;
|
||||
static Scotty.CompressionFormats targetFormat = Scotty.CompressionFormats.ZLIB;
|
||||
static byte targetStrength = 9;
|
||||
static long targetBlockSize = 65536; // in bytes
|
||||
|
@ -45,34 +46,40 @@ public class standalone {
|
|||
} else if (args.length > 0) {
|
||||
if (args[0].equals("-h")) {
|
||||
printHelpScreen();
|
||||
if (args.length > 1 && args[1].equals("-j")) {
|
||||
printAboutScreen();
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
for (String s : args) {
|
||||
if (!argIsTakingParam) {
|
||||
if (!argIsTakingParam) { // The options
|
||||
switch (s) {
|
||||
case "-j":
|
||||
argIsTakingParam = false;
|
||||
printAboutScreen();
|
||||
if (args.length == 1) {System.exit(0);}
|
||||
else if (args.length == 2 && args[1].equals("-h")) {
|
||||
printHelpScreen();
|
||||
System.exit(0);
|
||||
}
|
||||
break;
|
||||
case "-h":
|
||||
if (argWhichIsTakingParam == null) {
|
||||
printHelpScreen();
|
||||
} else {
|
||||
System.out.println("WARNING: Argument \"-h\" provided but other commands were already given first, ignoring.");
|
||||
}
|
||||
break;
|
||||
case "-q":
|
||||
argIsTakingParam = false;
|
||||
argWhichIsTakingParam = s;
|
||||
verbosity = Verbosities.QUIET;
|
||||
System.out.println("INFO: Set output to quiet mode.");
|
||||
break;
|
||||
case "-v":
|
||||
argIsTakingParam = false;
|
||||
argWhichIsTakingParam = s;
|
||||
verbosity = Verbosities.VERBOSE;
|
||||
System.out.println("INFO: Set output to verbose mode.");
|
||||
break;
|
||||
case "-y":
|
||||
argIsTakingParam = false;
|
||||
argWhichIsTakingParam = s;
|
||||
overwrite = true;
|
||||
System.out.println("INFO: Automatic overwrite enabled.");
|
||||
break;
|
||||
case "-i", "-t", "-e":
|
||||
argIsTakingParam = false;
|
||||
|
@ -80,23 +87,72 @@ public class standalone {
|
|||
setOperation(s);
|
||||
break;
|
||||
case "-I", "-c", "-E", "-x":
|
||||
if (s.equals("-c")) {throwUnimplementedAndThenCrash(s);} // todo
|
||||
argIsTakingParam = true;
|
||||
argWhichIsTakingParam = s;
|
||||
setOperation(s);
|
||||
break;
|
||||
case "-b", "-g", "-s":
|
||||
throwUnimplementedAndThenCrash(s); // todo
|
||||
argIsTakingParam = true;
|
||||
argWhichIsTakingParam = s;
|
||||
break;
|
||||
case "-u":
|
||||
argIsTakingParam = false;
|
||||
argWhichIsTakingParam = s;
|
||||
targetFormat = Scotty.CompressionFormats.NONE;
|
||||
break;
|
||||
case "-z":
|
||||
argIsTakingParam = false;
|
||||
argWhichIsTakingParam = s;
|
||||
targetFormat = Scotty.CompressionFormats.ZLIB;
|
||||
break;
|
||||
case "-l":
|
||||
argIsTakingParam = false;
|
||||
argWhichIsTakingParam = s;
|
||||
targetFormat = Scotty.CompressionFormats.LZMA;
|
||||
break;
|
||||
case "-r":
|
||||
argIsTakingParam = false;
|
||||
argWhichIsTakingParam = s;
|
||||
makeAbsolute = false;
|
||||
break;
|
||||
case "-a":
|
||||
argIsTakingParam = false;
|
||||
argWhichIsTakingParam = s;
|
||||
makeAbsolute = true;
|
||||
break;
|
||||
case "-n":
|
||||
argIsTakingParam = false;
|
||||
argWhichIsTakingParam = s;
|
||||
makeCaseInsensitive = true;
|
||||
break;
|
||||
default:
|
||||
System.out.println("invalid option: " + s);
|
||||
System.exit(1);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
} else { // And then the options for those options
|
||||
switch (argWhichIsTakingParam) {
|
||||
case "":
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (verbosity != Verbosities.QUIET) {
|
||||
System.out.println("INFO: absolute mode is " + makeAbsolute);
|
||||
System.out.println("INFO: case insensitive mode is " + makeCaseInsensitive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void throwUnimplementedAndThenCrash(String str) {
|
||||
System.out.println("Feature " + str + " is unimplemented. Closing.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
private static void setOperation(String str) {
|
||||
if (!operation.isEmpty()) {System.out.println("WARNING: duplicate operation " + str + " replaces previous argument.");}
|
||||
if (!operation.isEmpty()) {System.out.println("WARNING: duplicate operation " + str + " replaces previous argument \"" + operation + "\".");}
|
||||
operation = str;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user