Skip to content

Commit

Permalink
Merge pull request #21 from akshatjainei/test101
Browse files Browse the repository at this point in the history
Support for multiple URLs enabled
  • Loading branch information
SaptarshiSarkar12 authored Oct 1, 2022
2 parents 4bf20c4 + a59618c commit 0e699aa
Showing 1 changed file with 33 additions and 23 deletions.
56 changes: 33 additions & 23 deletions src/Drifty_CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,45 @@ public static void main(String[] args) {
System.out.println(ANSI_PURPLE+"===================================================================="+ANSI_RESET);
}
flag = true;
System.out.print("Enter the link to the file : ");
String link = SC.next();
SC.nextLine();
System.out.print("Enter the filename (with file extension) : ");
String fName = SC.nextLine();
while (true) {
System.out.print("Do you want to download the file in your default downloads folder? (Enter Y for yes and N for no) : ");
char default_folder = SC.nextLine().toLowerCase().charAt(0);
if (default_folder == 'y') {
downloadsFolder = DefaultDownloadFolderLocationFinder.findPath() + System.getProperty("file.separator");
if (downloadsFolder == null) {
System.out.println("Failed to retrieve default download folder!");
cl.log("ERROR", "Failed to retrieve default download folder!");
while(true) {
System.out.print("Enter the link to the file : ");
String link = SC.next();
SC.nextLine();
System.out.print("Enter the filename (with file extension) : ");
String fName = SC.nextLine();
while (true) {
System.out.print("Do you want to download the file in your default downloads folder? (Enter Y for yes and N for no) : ");
char default_folder = SC.nextLine().toLowerCase().charAt(0);
if (default_folder == 'y') {
downloadsFolder = DefaultDownloadFolderLocationFinder.findPath() + System.getProperty("file.separator");
if (downloadsFolder == null) {
System.out.println("Failed to retrieve default download folder!");
cl.log("ERROR", "Failed to retrieve default download folder!");
enterDownloadsFolder();
} else {
System.out.println("Default download folder detected : " + downloadsFolder);
cl.log("INFO", "Default download folder detected : " + downloadsFolder);
}
} else if (default_folder == 'n') {
enterDownloadsFolder();
} else {
System.out.println("Default download folder detected : " + downloadsFolder);
cl.log("INFO", "Default download folder detected : " + downloadsFolder);
System.out.println("Invalid input!");
cl.log("ERROR", "Invalid input");
continue;
}
} else if (default_folder == 'n') {
enterDownloadsFolder();
} else {
System.out.println("Invalid input!");
cl.log("ERROR", "Invalid input");
break;
}
FileDownloader fDownload = new FileDownloader(link, fName, downloadsFolder);
fDownload.run();
System.out.println("Press Q to Quit Or Press any Key to Continue");
String quit = SC.nextLine();
if(quit.equals("Q") || quit.equals("q")){
break;
}
else {
continue;
}
break;
}
FileDownloader fDownload = new FileDownloader(link, fName, downloadsFolder);
fDownload.run();
}

private static void enterDownloadsFolder(){
Expand Down

0 comments on commit 0e699aa

Please sign in to comment.