Ejemplo n.º 1
0
        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");
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
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);
        }