From 7ac19057cfe29f9d9dac2d5fc2bd38ab1ffbb792 Mon Sep 17 00:00:00 2001 From: Wickeddev123 Date: Sun, 22 Mar 2020 21:49:02 +1030 Subject: [PATCH] Added functionality so you can just enter a filepath to a directory instead of sending a billion file paths to the command line. Changes files: Program.cs Signed-off-by: Wickeddev123 --- LibCopy/Program.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/LibCopy/Program.cs b/LibCopy/Program.cs index e3722ea..7dc4604 100644 --- a/LibCopy/Program.cs +++ b/LibCopy/Program.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using CommandLine; //Todo: If Verbose is set, output the total size of the files. @@ -7,6 +8,7 @@ using CommandLine; // 0: Success // 1: Bad Directory // 2: Bad files (if all the files are bad for example a bad path) +// 3: Invalid command line data. namespace LibCopy { @@ -19,8 +21,12 @@ namespace LibCopy { [Option('v', "Verbose", Required = false, HelpText = "Outputs current state of the application.", Default = false)] public bool Verbose { get; set; } - [Option('f', "File Paths", Required = true, HelpText = "Location of the files that the application will copy.")] + [Option('f', "File Paths", Required = false, HelpText = "Location of the files that the application will copy.")] public string[] FilesToCopy { get; set; } + + [Option('x', "Directory", Required = false, HelpText = "copies everything inside of directory; just a bit more convenient than writing down a hundred file locations.")] + public string Xdirectory { get; set; } + [Option('d', "Directory to copy files into.", Required = true, HelpText = "Filepath where the files will be copied into.")] public string Directory { get; set; } } @@ -28,7 +34,14 @@ namespace LibCopy static void Main(string[] args) { Parser.Default.ParseArguments(args).WithParsed(o => { - Utils.Copy(o.FilesToCopy, o.Directory, o.Verbose); + if (Directory.Exists(o.Xdirectory)) + { + Utils.Copy(Directory.GetFiles(o.Xdirectory), o.Directory, o.Verbose); + } + else + { + Utils.Copy(o.FilesToCopy, o.Directory, o.Verbose); + } }); } }