예제 #1
0
        public Action Parse(string[] args)
        {
            var parseResults = new FlagsParser().Parse(args);

            var flags = parseResults.Item2;
            args = parseResults.Item1;

            if (flags.ContainsKey("?"))
                return () => new UsageCommand(commands).Execute(args, flags);

            if (args.Length > 0)
            {
                var arg = args[0];

                // is command?
                var command = commands.FirstOrDefault(x => x.IsTopLevel && x.Names.Any(y => y.IndexOf(arg) >= 0));
                if (command != null)
                {
                    return () => command.Execute(args, flags);
                }

                // must be a task
                flags.Add("taskname", arg);
                return () => new TaskCommand().Execute(args, flags);
            }
            else
            {
                flags.Add("taskname", "default");
                return () => new TaskCommand().Execute(args, flags);
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: modulexcite/pvc
        static void Main(string[] args)
        {
            var parseResults = new FlagsParser().Parse(args);
            PvcConsole.Configure(!parseResults.Item2.ContainsKey("ansi"));

            var task = new ArgumentHandler().Parse(parseResults);
            task();
        }