File tree Expand file tree Collapse file tree 3 files changed +65
-1
lines changed
src/main/java/nsusbloader/cli Expand file tree Collapse file tree 3 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,11 @@ public CommandLineInterface(String[] args) {
61
61
new TinfoilNet (tfnArguments );
62
62
return ;
63
63
}
64
+ if (cli .hasOption ("t" ) || cli .hasOption ("tinfoil" )){
65
+ final String [] tfArguments = cli .getOptionValues ("tinfoil" );
66
+ new TinfoilUsb (tfArguments );
67
+ return ;
68
+ }
64
69
}
65
70
catch (ParseException pe ){
66
71
System .out .println (pe .getLocalizedMessage () +
@@ -116,6 +121,13 @@ private Options createCliOptions(){
116
121
.hasArgs ()
117
122
.argName ("..." )
118
123
.build ();
124
+ /* Tinfoil/Awoo USB */
125
+ final Option tinfoilOption = Option .builder ("t" )
126
+ .longOpt ("tinfoil" )
127
+ .desc ("Install via Tinfoil/Awoo USB mode." )
128
+ .hasArgs ()
129
+ .argName ("FILE1 ..." )
130
+ .build ();
119
131
120
132
121
133
final OptionGroup group = new OptionGroup ();
@@ -124,6 +136,7 @@ private Options createCliOptions(){
124
136
group .addOption (cleanSettingsOption );
125
137
group .addOption (versionOption );
126
138
group .addOption (helpOption );
139
+ group .addOption (tinfoilOption );
127
140
128
141
options .addOptionGroup (group );
129
142
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ private void parseFilesArguments() throws IncorrectSetupException{
123
123
}
124
124
125
125
if (filesList .size () == 0 ) {
126
- throw new IncorrectSetupException ("File(s) doesn't exists .\n " +
126
+ throw new IncorrectSetupException ("File(s) doesn't exist .\n " +
127
127
"Try 'ns-usbloader -n help' for more information." );
128
128
}
129
129
}
Original file line number Diff line number Diff line change
1
+ package nsusbloader .cli ;
2
+
3
+ import nsusbloader .COM .ICommunications ;
4
+ import nsusbloader .COM .USB .UsbCommunications ;
5
+
6
+ import java .io .File ;
7
+ import java .util .ArrayList ;
8
+ import java .util .List ;
9
+
10
+ public class TinfoilUsb {
11
+
12
+ private final String [] arguments ;
13
+ private List <File > filesList ;
14
+
15
+ public TinfoilUsb (String [] arguments ) throws InterruptedException , IncorrectSetupException {
16
+ this .arguments = arguments ;
17
+ checkArguments ();
18
+ parseFilesArguments ();
19
+ runTinfoilBackend ();
20
+ }
21
+
22
+ private void checkArguments () throws IncorrectSetupException {
23
+ if (arguments == null || arguments .length == 0 ) {
24
+ throw new IncorrectSetupException ("No files?\n " +
25
+ "Try 'ns-usbloader -h' for more information." );
26
+ }
27
+ }
28
+
29
+ private void parseFilesArguments () throws IncorrectSetupException {
30
+ filesList = new ArrayList <>();
31
+ File file ;
32
+
33
+ for (String arg : arguments ) {
34
+ file = new File (arg );
35
+ if (file .exists ())
36
+ filesList .add (file );
37
+ }
38
+
39
+ if (filesList .size () == 0 ) {
40
+ throw new IncorrectSetupException ("File(s) doesn't exist.\n " +
41
+ "Try 'ns-usbloader -n help' for more information." );
42
+ }
43
+ }
44
+
45
+ private void runTinfoilBackend () throws InterruptedException {
46
+ ICommunications task = new UsbCommunications (filesList , "TinFoil" , false );
47
+ Thread thread = new Thread (task );
48
+ thread .start ();
49
+ thread .join ();
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments