Пример #1
0
        public override void Run(string[] args)
        {
            options = new CmdParserOptionSet()
            {
                { "h|help", "Display this help information. To see online help, use: git help <command>", v => OfflineHelp() },
                { "l", "Cause the logical variables to be listed", v => cmd.L = true },
            };

            try
            {
                List <String> arguments = ParseOptions(args);
                if (arguments.Count > 0)
                {
                    cmd.Arguments = arguments;
                    cmd.Execute();
                }
                else
                {
                    OfflineHelp();
                }
            }
            catch (Exception e)
            {
                cmd.OutputStream.WriteLine(e.Message);
            }
        }
Пример #2
0
        public void ExecuteVarCommandWithNullExpression()
        {
            VarCommand command = new VarCommand("foo", null);

            IBindingEnvironment environment = new BindingEnvironment();
            IBindingEnvironment local       = new LocalBindingEnvironment(environment);
            IBindingEnvironment local2      = new LocalBindingEnvironment(local);

            command.Execute(local2);

            Assert.IsTrue(local2.ContainsName("foo"));
            Assert.IsFalse(local.ContainsName("foo"));
            Assert.IsFalse(environment.ContainsName("foo"));

            Assert.IsNull(local2.GetValue("foo"));
        }
Пример #3
0
        public void ExecuteVarCommand()
        {
            VarCommand command = new VarCommand("foo", new ConstantExpression(10));

            IBindingEnvironment environment = new BindingEnvironment();
            IBindingEnvironment local       = new LocalBindingEnvironment(environment);
            IBindingEnvironment local2      = new LocalBindingEnvironment(local);

            command.Execute(local2);

            Assert.IsTrue(local2.ContainsName("foo"));
            Assert.IsFalse(local.ContainsName("foo"));
            Assert.IsFalse(environment.ContainsName("foo"));

            Assert.AreEqual(10, local2.GetValue("foo"));
        }