Ejemplo n.º 1
0
        public void AllTest()
        {
            var argumentHelper = new ArgumentHelper();

            argumentHelper.Configure()
            .Option("-h", "--help").Description("Show help.").Configure()
            .Option("-i", "--input").Description("Input file.").HasValue().Configure()
            .Command("help").Description("Show help.").Configure()
            .Command("input").Description("Input file.").HasValue().Configure()
            .Argument("input");
            var usage = argumentHelper.GetUsage();

            var expected = new StringBuilder();

            expected.AppendLine("Usage: [options] [commands] [input]");
            expected.AppendLine();
            expected.AppendLine("options:");
            expected.AppendLine("  -h|--help     Show help.");
            expected.AppendLine("  -i|--input    Input file.");
            expected.AppendLine();
            expected.AppendLine("commands:");
            expected.AppendLine("  help  Show help.");
            expected.AppendLine("  input Input file.");

            Assert.AreEqual(expected.ToString(), usage);
        }
Ejemplo n.º 2
0
        public void ArgumentsTest()
        {
            var argumentHelper = new ArgumentHelper();

            argumentHelper.Configure()
            .Argument("arg1");
            var usage = argumentHelper.GetUsage();

            var expected = new StringBuilder();

            expected.AppendLine("Usage: [arg1]");

            Assert.AreEqual(expected.ToString(), usage);
        }
Ejemplo n.º 3
0
        public void CommandDoesNotTouchDescriptionWhenCharsAreAtTabEndTest()
        {
            var argumentHelper = new ArgumentHelper();

            argumentHelper.Configure()
            .Command("345678").Description("description");
            var usage = argumentHelper.GetUsage();

            var expected = new StringBuilder();

            expected.AppendLine("Usage: [commands]");
            expected.AppendLine();
            expected.AppendLine("commands:");
            expected.AppendLine("  345678        description");

            Assert.AreEqual(expected.ToString(), usage);
        }
Ejemplo n.º 4
0
        public void OptionDoesNotTouchDescriptionWhenCharsAreAtTabEndTest()
        {
            var argumentHelper = new ArgumentHelper();

            argumentHelper.Configure()
            .Option("-a", "--abcdefghi").Description("description");
            var usage = argumentHelper.GetUsage();

            var expected = new StringBuilder();

            expected.AppendLine("Usage: [options]");
            expected.AppendLine();
            expected.AppendLine("options:");
            expected.AppendLine("  -a|--abcdefghi        description");

            Assert.AreEqual(expected.ToString(), usage);
        }