예제 #1
0
        public new void Execute(FigaroContext context, string args)
        {
            base.Execute(context, args);

            if (argv.Length == 3)
            {
                switch (argv[2])
                {
                case "f":
                    context.PutDocumentByFile(argv[0]);
                    return;

                case "s":
                    context.PutDocumentByString(argv[0], argv[1].Replace("{", string.Empty).Replace("}", string.Empty));
                    return;

                case "q":
                    context.PutDocumentByQuery(argv[0], argv[1]);
                    return;
                }
            }
            else if (argv.Length == 2)
            {
                var res = from opt in new[] { "f", "s", "q" }
                where argv[1].Equals(opt)
                select opt;
                if (res.Count() > 0)
                {
                    PutDoc(res.First());
                }
                else
                {
                    context.PutDocumentByString(argv[0], argv[1]);
                }
            }
            else if (argv.Length == 1)
            {
                ctx.PutDocumentByString(argv[0], string.Empty);
            }
            else
            {
                WarnUsage();
                throw new ValidationException();
            }
        }