Beispiel #1
0
        static int Main(string[] args)
        {
            var cmdParam = new CmdParam(args);

            if (cmdParam.ContainsUasgeParam())
            {
                Console.WriteLine(CmdMessage.GetUsage());
            }
            else if (cmdParam.IsError())
            {
                Console.WriteLine(CmdMessage.GetUsageErrorPrompt());
                return(Error);
            }
            else
            {
                ShowCurrentDirectory();
                var cmdEntry = new CmdEntry(cmdParam);
                foreach (var line in cmdEntry.GetExecuteResult())
                {
                    Console.WriteLine(line);
                }
            }

            return(Success);
        }
        public void should_return_false_when_args_not_contains_the_usage_parameter()
        {
            var cmdParam1 = new CmdParam(new[] { "6", " ", "/x" });
            var cmdParam2 = new CmdParam(new string[] { });

            Assert.AreEqual(false, cmdParam1.ContainsUasgeParam());
            Assert.AreEqual(false, cmdParam2.ContainsUasgeParam());
        }
Beispiel #3
0
        public void should_return_true_when_args_contains_the_usage_parameter()
        {
            var cmdParam1 = new CmdParam(new[] { "/f", "/?" });
            var cmdParam2 = new CmdParam(new[] { "/?" });

            Assert.AreEqual(true, cmdParam1.ContainsUasgeParam());
            Assert.AreEqual(true, cmdParam2.ContainsUasgeParam());
        }
        public static int Main(string[] args)
        {
            var cmdParam = new CmdParam(args);

            if (cmdParam.ContainsUasgeParam())
            {
                Console.WriteLine(CmdMessage.GetUsage());
            }
            else if (Console.IsInputRedirected)
            {
                var cmdEntry = new CmdEntry(GetRedirectedInput(), cmdParam);
                foreach (var line in cmdEntry.GetExecuteResult())
                {
                    Console.WriteLine(line);
                }
            }
            else
            {
                Console.WriteLine(CmdMessage.GetUsageErrorPrompt());
                return(Error);
            }
            return(Success);
        }