Added -t to tell Sherly the number of Threads it should use

This commit is contained in:
BlyDoesCoding 2023-03-20 21:48:44 +01:00
parent 639afceab8
commit d3ca5f7ace
3 changed files with 26 additions and 4 deletions

16
.idea/workspace.xml generated
View file

@ -9,8 +9,10 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="9b57ac51-c870-474b-9dfd-64a5fc490635" name="Changes" comment="Update deletion behavior and fixed file == NULL bug">
<list default="true" id="9b57ac51-c870-474b-9dfd-64a5fc490635" name="Changes" comment="Update README.md according to the new deletion behavior">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -214,7 +216,14 @@
<option name="project" value="LOCAL" />
<updated>1679344271798</updated>
</task>
<option name="localTasksCounter" value="18" />
<task id="LOCAL-00018" summary="Update README.md according to the new deletion behavior">
<created>1679344426853</created>
<option name="number" value="00018" />
<option name="presentableId" value="LOCAL-00018" />
<option name="project" value="LOCAL" />
<updated>1679344426853</updated>
</task>
<option name="localTasksCounter" value="19" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -253,7 +262,8 @@
<MESSAGE value="Added -h / -help option for better usability" />
<MESSAGE value="Rework of README.md" />
<MESSAGE value="Update deletion behavior and fixed file == NULL bug" />
<option name="LAST_COMMIT_MESSAGE" value="Update deletion behavior and fixed file == NULL bug" />
<MESSAGE value="Update README.md according to the new deletion behavior" />
<option name="LAST_COMMIT_MESSAGE" value="Update README.md according to the new deletion behavior" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>

View file

@ -12,6 +12,7 @@ Usage: sherly -f inputfolder1 inputfolder2 inputfolder3 [options]...
-h / -help show this
-f / -folder all the folders you want to scan for (see example above!)
-c / -color enable colored messages
-t / -threads override default Thread number (default is usually number of cores * 2)
-p / -progress enable progress indicator
-d / -delete delete all dups except one without asking first
-debug debug stuff

View file

@ -21,6 +21,8 @@ public class Main {
boolean showProgress = false;
boolean deleteDups = false;
boolean recordFolder = false;
boolean recordThreads = false;
int saidThreads = 0;
boolean showDebug = false;
boolean help = false;
@ -33,9 +35,14 @@ public class Main {
paths.add(i);
} else {recordFolder = false;}
}
if (recordThreads) {
saidThreads = Integer.parseInt(i);
recordThreads = false;
}
if (i.equalsIgnoreCase("-c") || i.equalsIgnoreCase("-color")) { doTheColorThingy = true;}
if (i.equalsIgnoreCase("-p") || i.equalsIgnoreCase("-progress")) { showProgress = true;}
if (i.equalsIgnoreCase("-f") || i.equalsIgnoreCase("-folder")) { recordFolder = true;}
if (i.equalsIgnoreCase("-t") || i.equalsIgnoreCase("-threads")) { recordThreads = true;}
if (i.equalsIgnoreCase("-d") || i.equalsIgnoreCase("-delete")) { deleteDups = true;}
if (i.equalsIgnoreCase("-h") || i.equalsIgnoreCase("-help")) { help = true;}
if (i.equalsIgnoreCase("-debug")) { showDebug = true;}
@ -48,6 +55,7 @@ public class Main {
System.out.println(" -h / -help show this");
System.out.println(" -f / -folder all the folders you want to scan for (see example above!)");
System.out.println(" -c / -color enable colored messages");
System.out.println(" -t / -threads override default Thread number (default is usually number of cores * 2)");
System.out.println(" -p / -progress enable progress indicator");
System.out.println(" -d / -delete delete all dups except one without asking first");
System.out.println(" -debug debug stuff");
@ -63,6 +71,7 @@ public class Main {
System.out.println("Color: " + doTheColorThingy);
System.out.println("Delete: " + deleteDups);
System.out.println("Progressbar: " + showProgress);
System.out.println("Commanded Threads " + saidThreads);
}
@ -78,10 +87,12 @@ public class Main {
allFiles.addAll(pathList);
}
// calculations for multithreading
// calculations for multithreading
//The number of Cores or better said Threads that can be used
int availableThreads = Runtime.getRuntime().availableProcessors();
if (saidThreads != 0) {availableThreads = saidThreads;}
//just the number of All Files in all Folders taken from the Args
int filesToBeDone = allFiles.size();