From 9a0d2afb36f79bb8a625851f6292935a5e955d9d Mon Sep 17 00:00:00 2001 From: Anurag-Bharati Date: Sun, 2 Oct 2022 19:24:50 +0545 Subject: [PATCH 1/2] Added support for program args --- src/Drifty_CLI.java | 74 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/src/Drifty_CLI.java b/src/Drifty_CLI.java index bbee6ac47..dd8eb63b1 100644 --- a/src/Drifty_CLI.java +++ b/src/Drifty_CLI.java @@ -1,4 +1,7 @@ import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Objects; import java.util.Scanner; public class Drifty_CLI { @@ -10,6 +13,7 @@ public class Drifty_CLI { public static final String ANSI_PURPLE = "\u001B[35m"; private static boolean flag = false; private static String fName = null; + public static void main(String[] args) { logger.log("INFO", "Application Started !"); if (!flag) { @@ -23,6 +27,42 @@ public static void main(String[] args) { System.out.println(ANSI_PURPLE+"===================================================================="+ANSI_RESET); } flag = true; + if (args.length > 0){ + String URL = args[0]; + String name = null; + String location = null; + for (int i = 0; i Date: Sun, 2 Oct 2022 22:26:38 +0545 Subject: [PATCH 2/2] Added -help argument. --- src/Drifty_CLI.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Drifty_CLI.java b/src/Drifty_CLI.java index dd8eb63b1..d322bc1ce 100644 --- a/src/Drifty_CLI.java +++ b/src/Drifty_CLI.java @@ -184,6 +184,16 @@ private static String getCurrentTimeAsName(){ } private static void help(){ - // TODO MINI DOC + System.out.println(ANSI_RESET+"\n\033[38;31;48;40;1m--=| DRIFTY CLI HELP |=--"+ANSI_RESET); + System.out.println("\033[38;31;48;40;0m v 1.1.0"+ANSI_RESET); + System.out.println("For more information visit: https://github.com/SaptarshiSarkar12/Drifty/"); + System.out.println("\033[31;1mRequired parameter: File URL"+ANSI_RESET+" \033[3m(This must be the first arg. you pass)"+ANSI_RESET); + System.out.println("\033[33;1mOptional parameters:"); + System.out.println("\033[97;1mName ShortForm Default Description"+ANSI_RESET); + System.out.println("-location -l Downloads The location on your computer where content downloaded from Drifty are placed."); + System.out.println("-name -n Source Renames file."); + System.out.println("-help -h N/A Provides concise information for Drifty CLI.\n"); + System.out.println("\033[97;1mExample:" + ANSI_RESET + " \n> \033[37;1mjava Drifty_CLI https://example.com/object.png -n obj.png -l C:/Users/example"+ ANSI_RESET ); + System.out.println("\033[37;3m* Requires java 18 or higher. \n"+ANSI_RESET); } }