diff --git a/EtchBendLines/BendLineExtractor.cs b/EtchBendLines/BendLineExtractor.cs index 0be7f37..7872ea3 100644 --- a/EtchBendLines/BendLineExtractor.cs +++ b/EtchBendLines/BendLineExtractor.cs @@ -6,7 +6,7 @@ using System.Text.RegularExpressions; namespace EtchBendLines { - class BendLineExtractor + public class BendLineExtractor { public BendLineExtractor(string dxfFile) { diff --git a/EtchBendLines/Program.cs b/EtchBendLines/Program.cs index d234598..221263e 100644 --- a/EtchBendLines/Program.cs +++ b/EtchBendLines/Program.cs @@ -3,25 +3,41 @@ using System.Collections.Generic; using System.Configuration; using System.IO; using System.Linq; -using System.Text.RegularExpressions; namespace EtchBendLines { public class Program { - static Etcher etcher = new Etcher(); - static void Main(string[] args) { try { - var path = AppDomain.CurrentDomain.BaseDirectory; - var files = Directory.GetFiles(path, "*.dxf", SearchOption.AllDirectories); - + var etcher = new Etcher(); etcher.EtchLength = GetAppSettingAsDouble("EtchLength"); etcher.MaxBendRadius = GetAppSettingAsDouble("MaxBendRadius"); - if (files == null || files.Length == 0) + var paths = new List(args); + + if (paths.Count == 0) + { + paths.Add(AppDomain.CurrentDomain.BaseDirectory); + } + + var files = new List(); + + 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."); }