private static void AdjustShellCommandData(ShellCommands shCmds) { if (shCmds.Directory != null) { shCmds.Files = Directory.GetFiles(shCmds.Directory, "*.csv"); } if (shCmds.Files == null) { shCmds.Files = Directory.GetFiles(Environment.CurrentDirectory, "*.csv"); } }
private static void ProcessShellCommands(ShellCommands shellCmds) { foreach (string s in shellCmds.Files) { var items = Read(s); FileInfo fi = new FileInfo(s); string path = EnsureOutDirectory(fi.DirectoryName); path = Path.Combine(path, fi.Name); Write(items, path, shellCmds.ToMyLocalFormat, shellCmds.Columns); } }
static void Main(string[] args) { ShellCommands shCmds = null; try { _isInteractive = !args.Any() || Debugger.IsAttached; if (_isInteractive) { PrintWelcomeMessage(); } shCmds = ParseShellCommands(args); AdjustShellCommandData(shCmds); if (!_isJustHelp) { ProcessShellCommands(shCmds); } } catch (Exception e) { Console.WriteLine(e); if (shCmds != null) { Console.WriteLine(shCmds.GetUsage()); } Environment.ExitCode = -1; } if (_isInteractive) { PrintGoodByMessage(Environment.ExitCode == 0); } }
private static ShellCommands ParseShellCommands(string [] args) { ShellCommands shellCmds = new ShellCommands(); if (!CommandLine.Parser.Default.ParseArguments(args, shellCmds)) { if (args.Length == 0) { shellCmds.Files = Directory.GetFiles(Environment.CurrentDirectory, "*.csv"); } else if (args.Length == 1 && args[0] == "-?") { _isJustHelp = true; _isInteractive = true; } else { shellCmds.Files = args; } } return(shellCmds); }