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 <wickedempire111@outlook.com>
This commit is contained in:
2020-03-22 21:49:02 +10:30
parent 335522ee63
commit 7ac19057cf
+15 -2
View File
@@ -1,4 +1,5 @@
using System; using System;
using System.IO;
using CommandLine; using CommandLine;
//Todo: If Verbose is set, output the total size of the files. //Todo: If Verbose is set, output the total size of the files.
@@ -7,6 +8,7 @@ using CommandLine;
// 0: Success // 0: Success
// 1: Bad Directory // 1: Bad Directory
// 2: Bad files (if all the files are bad for example a bad path) // 2: Bad files (if all the files are bad for example a bad path)
// 3: Invalid command line data.
namespace LibCopy namespace LibCopy
{ {
@@ -19,8 +21,12 @@ namespace LibCopy
{ {
[Option('v', "Verbose", Required = false, HelpText = "Outputs current state of the application.", Default = false)] [Option('v', "Verbose", Required = false, HelpText = "Outputs current state of the application.", Default = false)]
public bool Verbose { get; set; } 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; } 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.")] [Option('d', "Directory to copy files into.", Required = true, HelpText = "Filepath where the files will be copied into.")]
public string Directory { get; set; } public string Directory { get; set; }
} }
@@ -28,7 +34,14 @@ namespace LibCopy
static void Main(string[] args) static void Main(string[] args)
{ {
Parser.Default.ParseArguments<Options>(args).WithParsed(o => { Parser.Default.ParseArguments<Options>(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);
}
}); });
} }
} }