cli args handling WIP

This commit is contained in:
Downforce Agent 2024-08-12 22:57:26 -05:00
parent 20e31468b3
commit e7e0111f48
2 changed files with 80 additions and 15 deletions

View File

@ -9,7 +9,7 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <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$/.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" /> <change beforePath="$PROJECT_DIR$/net/screwgravity/vitality4j/standalone.java" beforeDir="false" afterPath="$PROJECT_DIR$/net/screwgravity/vitality4j/standalone.java" afterDir="false" />
</list> </list>
@ -99,7 +99,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1723514215355</updated> <updated>1723514215355</updated>
</task> </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 /> <servers />
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
@ -108,6 +116,7 @@
<MESSAGE value="initial structuring" /> <MESSAGE value="initial structuring" />
<MESSAGE value="rebase; move to package, prepare header read io" /> <MESSAGE value="rebase; move to package, prepare header read io" />
<MESSAGE value="brb, eating" /> <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> </component>
</project> </project>

View File

@ -13,6 +13,7 @@ public class standalone {
static String operation = ""; static String operation = "";
static String targetPath; // psarc file static String targetPath; // psarc file
static String sourcePath; // folder contents to import when using -c, list of files to export when using -x 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 Scotty.CompressionFormats targetFormat = Scotty.CompressionFormats.ZLIB;
static byte targetStrength = 9; static byte targetStrength = 9;
static long targetBlockSize = 65536; // in bytes static long targetBlockSize = 65536; // in bytes
@ -45,34 +46,40 @@ public class standalone {
} else if (args.length > 0) { } else if (args.length > 0) {
if (args[0].equals("-h")) { if (args[0].equals("-h")) {
printHelpScreen(); printHelpScreen();
if (args.length > 1 && args[1].equals("-j")) {
printAboutScreen();
}
System.exit(0); System.exit(0);
} }
for (String s : args) { for (String s : args) {
if (!argIsTakingParam) { if (!argIsTakingParam) { // The options
switch (s) { switch (s) {
case "-j": case "-j":
argIsTakingParam = false; argIsTakingParam = false;
printAboutScreen(); printAboutScreen();
if (args.length == 1) {System.exit(0);}
else if (args.length == 2 && args[1].equals("-h")) {
printHelpScreen();
System.exit(0);
}
break; break;
case "-h": case "-h":
if (argWhichIsTakingParam == null) { System.out.println("WARNING: Argument \"-h\" provided but other commands were already given first, ignoring.");
printHelpScreen();
} else {
System.out.println("WARNING: Argument \"-h\" provided but other commands were already given first, ignoring.");
}
break; break;
case "-q": case "-q":
argIsTakingParam = false; argIsTakingParam = false;
argWhichIsTakingParam = s; argWhichIsTakingParam = s;
verbosity = Verbosities.QUIET; verbosity = Verbosities.QUIET;
System.out.println("INFO: Set output to quiet mode.");
break; break;
case "-v": case "-v":
argIsTakingParam = false; argIsTakingParam = false;
argWhichIsTakingParam = s; argWhichIsTakingParam = s;
verbosity = Verbosities.VERBOSE; 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; break;
case "-i", "-t", "-e": case "-i", "-t", "-e":
argIsTakingParam = false; argIsTakingParam = false;
@ -80,23 +87,72 @@ public class standalone {
setOperation(s); setOperation(s);
break; break;
case "-I", "-c", "-E", "-x": case "-I", "-c", "-E", "-x":
if (s.equals("-c")) {throwUnimplementedAndThenCrash(s);} // todo
argIsTakingParam = true; argIsTakingParam = true;
argWhichIsTakingParam = s; argWhichIsTakingParam = s;
setOperation(s); setOperation(s);
break; 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: default:
System.out.println("invalid option: " + s); System.out.println("invalid option: " + s);
System.exit(1);
break; 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) { 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; operation = str;
} }