Ejemplo n.º 1
0
        public void CanParseArgumentsWithNewLine()
        {
            IDictionary <string, string> args = LexArgs.Parse(" appid=knowledgedrink QA " + Environment.NewLine);

            Assert.AreEqual(args.Count, 2);
            Assert.IsTrue(args.ContainsKey("appid=knowledgedrink"));
            Assert.IsTrue(args.ContainsKey("QA"));
        }
Ejemplo n.º 2
0
        public void CanParseArgumentsWithTabs()
        {
            IDictionary <string, string> args = LexArgs.Parse(" 'squote'	's\"quote'	's\\'quote'");

            Assert.IsTrue(args.ContainsKey("squote"));
            Assert.IsTrue(args.ContainsKey("s\"quote"));
            Assert.IsTrue(args.ContainsKey("s'quote"));
            Assert.AreEqual(args.Count, 3);
        }
Ejemplo n.º 3
0
        public void CanParseArguments()
        {
            IDictionary <string, string> args = LexArgs.Parse(" pythontests.py  --config=\"prod.config\"  --trace=4  BLOGS 'c: d: e:'");

            Assert.IsTrue(args.ContainsKey("pythontests.py"));
            Assert.IsTrue(args.ContainsKey("--config=\"prod.config\""));
            Assert.IsTrue(args.ContainsKey("--trace=4"));
            Assert.IsTrue(args.ContainsKey("BLOGS"));
            Assert.IsTrue(args.ContainsKey("c: d: e:"));
            Assert.AreEqual(args.Count, 5);
        }
Ejemplo n.º 4
0
        public void CanParseArgumentsQuoted()
        {
            IDictionary <string, string> args = LexArgs.Parse(" 'squote' 's\"quote' 's\\'quote' \"dquote\" \"d'quote\" \"d\\\"quote\"");

            Assert.IsTrue(args.ContainsKey("squote"));
            Assert.IsTrue(args.ContainsKey("s\"quote"));
            Assert.IsTrue(args.ContainsKey("s'quote"));
            Assert.IsTrue(args.ContainsKey("dquote"));
            Assert.IsTrue(args.ContainsKey("d'quote"));
            Assert.IsTrue(args.ContainsKey("d\"quote"));
            Assert.AreEqual(args.Count, 6);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Parses the arguments and checks for named arguments and non-named arguments.
 /// </summary>
 /// <param name="args">e.g. "-config:prod.xml", "-date:T-1", "BloombergFutOpt"</param>
 /// <param name="prefix">Character used to identifiy the name
 /// of a named parameter. e.g. "-" as in "-config:prod.xml"
 /// Leave null or string.emtpy to indicate there is no prefix.
 /// In which case, only the <paramref name="separator"/> is used to distinguish
 /// namevalue pairs.</param>
 /// <param name="separator">Character used to separate the named
 /// argument with it's value in a named argument. e.g. ":" as in "-config:prod.xml"
 /// If this is null or string.empty, in addition to the <paramref name="prefix"/></param>
 /// <returns></returns>
 public static BoolMessageItem <Args> Parse(string text, string prefix, string separator, object argReciever)
 {
     return(TryCatch(() => Parse(LexArgs.ParseList(text).ToArray(), prefix, separator, argReciever)));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Parse the line into a collection of arguments.
 /// </summary>
 /// <param name="text">"-config:prod.xml -date:T-1 BloombergFutOpt"</param>
 /// <returns></returns>
 public static BoolMessageItem <Args> Parse(string text)
 {
     return(TryCatch(() => Parse(LexArgs.ParseList(text).ToArray())));
 }