Minor fixes

This commit is contained in:
Dmitry Isaenko 2023-02-09 15:25:13 +03:00
parent 4d7c6f6ef1
commit 29f29b7d31
24 changed files with 139 additions and 42 deletions

View file

@ -67,6 +67,11 @@ public class CommandLineInterface {
new GoldLeafCli(arguments);
return;
}
if (cli.hasOption("experimental")){
final String[] arguments = cli.getOptionValues("experimental");
new ExperimentalCli(arguments);
return;
}
/*
if (cli.hasOption("x") || cli.hasOption("nxdt")){
final String[] arguments = cli.getOptionValues("nxdt");
@ -153,6 +158,12 @@ public class CommandLineInterface {
.hasArgs()
.argName("...")
.build();
final Option experimentalOption = Option.builder()
.longOpt("experimental")
.desc("Enable testing and experimental functions")
.hasArgs()
.argName("y|n")
.build();
/* nxdumptool */
/*
final Option nxdtOption = Option.builder("x")
@ -183,6 +194,7 @@ public class CommandLineInterface {
group.addOption(helpOption);
group.addOption(tinfoilOption);
group.addOption(glOption);
group.addOption(experimentalOption);
//group.addOption(nxdtOption);
group.addOption(splitOption);
group.addOption(mergeOption);

View file

@ -0,0 +1,46 @@
/*
Copyright 2019-2023 Dmitry Isaenko
This file is part of NS-USBloader.
NS-USBloader is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
NS-USBloader is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with NS-USBloader. If not, see <https://www.gnu.org/licenses/>.
*/
package nsusbloader.cli;
import nsusbloader.AppPreferences;
public class ExperimentalCli {
ExperimentalCli(String[] arguments) throws IncorrectSetupException{
if (arguments == null || arguments.length == 0)
throw new IncorrectSetupException("No arguments.\nShould be 'y' or 'n'");
if (arguments.length > 1)
throw new IncorrectSetupException("Too many arguments.\nShould be 'y' or 'n' only");
String arg = arguments[0].toLowerCase().substring(0, 1);
if (arg.equals("y")) {
AppPreferences.getInstance().setPatchesTabInvisible(false);
System.out.println("Experimental functions enabled");
return;
}
if (arg.equals("n")) {
AppPreferences.getInstance().setPatchesTabInvisible(true);
System.out.println("Experimental functions disabled");
return;
}
throw new IncorrectSetupException("Incorrect arguments.\nCould be 'y' or 'n' only");
}
}

View file

@ -34,7 +34,7 @@ public class GoldLeafCli {
private int parseFileSince = 1;
public GoldLeafCli(String[] arguments) throws InterruptedException, IncorrectSetupException{
GoldLeafCli(String[] arguments) throws InterruptedException, IncorrectSetupException{
this.arguments = arguments;
checkArguments();
@ -43,7 +43,7 @@ public class GoldLeafCli {
runGoldLeafBackend();
}
public void checkArguments() throws IncorrectSetupException{
private void checkArguments() throws IncorrectSetupException{
if (arguments == null || arguments.length == 0) {
throw new IncorrectSetupException("No arguments.\n" +
"Try 'ns-usbloader -g help' for more information.");
@ -83,7 +83,7 @@ public class GoldLeafCli {
return builder.toString();
}
public void parseGoldLeafVersion() throws IncorrectSetupException{
private void parseGoldLeafVersion() throws IncorrectSetupException{
String argument1 = arguments[0];
if (! argument1.startsWith("ver=")) {
@ -107,7 +107,7 @@ public class GoldLeafCli {
getGlSupportedVersions());
}
public void parseFilesArguments() throws IncorrectSetupException{
private void parseFilesArguments() throws IncorrectSetupException{
filesList = new ArrayList<>();
File file;
@ -123,7 +123,7 @@ public class GoldLeafCli {
}
}
public void runGoldLeafBackend() throws InterruptedException {
private void runGoldLeafBackend() throws InterruptedException {
Runnable task = new UsbCommunications(filesList,
"GoldLeaf"+goldLeafVersion,
filterForNsp);

View file

@ -27,7 +27,7 @@ public class NxdtCli {
private final String[] arguments;
private String saveTo;
public NxdtCli(String[] arguments) throws InterruptedException, IncorrectSetupException{
NxdtCli(String[] arguments) throws InterruptedException, IncorrectSetupException{
this.arguments = arguments;
parseArgument();
runBackend();

View file

@ -29,7 +29,7 @@ public class TinfoilUsbCli {
private final String[] arguments;
private List<File> filesList;
public TinfoilUsbCli(String[] arguments) throws InterruptedException, IncorrectSetupException{
TinfoilUsbCli(String[] arguments) throws InterruptedException, IncorrectSetupException{
this.arguments = arguments;
checkArguments();
parseFilesArguments();