Allow multiple paths passed through args

This commit is contained in:
AJ
2021-04-07 22:00:11 -04:00
parent 2b30498147
commit 3e4ab60366
2 changed files with 24 additions and 8 deletions

View File

@@ -6,7 +6,7 @@ using System.Text.RegularExpressions;
namespace EtchBendLines namespace EtchBendLines
{ {
class BendLineExtractor public class BendLineExtractor
{ {
public BendLineExtractor(string dxfFile) public BendLineExtractor(string dxfFile)
{ {

View File

@@ -3,25 +3,41 @@ using System.Collections.Generic;
using System.Configuration; using System.Configuration;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
namespace EtchBendLines namespace EtchBendLines
{ {
public class Program public class Program
{ {
static Etcher etcher = new Etcher();
static void Main(string[] args) static void Main(string[] args)
{ {
try try
{ {
var path = AppDomain.CurrentDomain.BaseDirectory; var etcher = new Etcher();
var files = Directory.GetFiles(path, "*.dxf", SearchOption.AllDirectories);
etcher.EtchLength = GetAppSettingAsDouble("EtchLength"); etcher.EtchLength = GetAppSettingAsDouble("EtchLength");
etcher.MaxBendRadius = GetAppSettingAsDouble("MaxBendRadius"); etcher.MaxBendRadius = GetAppSettingAsDouble("MaxBendRadius");
if (files == null || files.Length == 0) var paths = new List<string>(args);
if (paths.Count == 0)
{
paths.Add(AppDomain.CurrentDomain.BaseDirectory);
}
var files = new List<string>();
foreach (var path in paths)
{
if (File.Exists(path))
{
files.Add(path);
}
else if (Directory.Exists(path))
{
files.AddRange(Directory.GetFiles(path, "*.dxf", SearchOption.AllDirectories));
}
}
if (files.Count == 0)
{ {
Console.WriteLine($"No DXF files founds. Place DXF files in \"{AppDomain.CurrentDomain.BaseDirectory}\" and run this program again."); Console.WriteLine($"No DXF files founds. Place DXF files in \"{AppDomain.CurrentDomain.BaseDirectory}\" and run this program again.");
} }