Пример #1
0
        /// <summary>
        /// Writes the list of valid command line arguments.
        /// </summary>
        private static void WriteUsage()
        {
            //
            // Define table
            //
            var options = new OptionsParser <CommandLineOptions>().GetOptions();

            //
            // Setup layout
            //
            int[] columnLengths = new int[] { 25, 10, 45 };

            //
            // Write headings
            //
            Console.Write("Argument" + new string(' ', columnLengths[0] - "Argument".Length));
            Console.Write("Required" + new string(' ', columnLengths[1] - "Required".Length));
            Console.Write("Description" + new string(' ', columnLengths[2] - "Description".Length));
            Console.Write(new string('=', Console.WindowWidth));

            //
            // Write table
            //
            foreach (var option in options.OrderByDescending(o => o.IsRequired).ThenBy(o => o.Name))
            {
                string[] row = new string[]
                {
                    option.Name,
                    option.IsRequired ? "Y" : "N",
                    option.Description
                };

                for (int i = 0; i < row.Length; i++)
                {
                    //
                    // Write max width columns
                    //
                    while (row[i].Length > columnLengths[i])
                    {
                        int x = Console.CursorLeft;
                        Console.Write(row[i].Substring(0, columnLengths[i]));
                        row[i]             = row[i].Substring(columnLengths[i]);
                        Console.CursorLeft = x;
                    }

                    //
                    // Write remainder
                    //
                    Console.Write(row[i]);
                    Console.Write(new string(' ', columnLengths[i] - row[i].Length));
                }

                Console.WriteLine();
            }
        }
Пример #2
0
        /// <summary>
        /// Writes the list of valid command line arguments.
        /// </summary>
        private static void WriteUsage()
        {
            //
            // Define table
            //
            var options = new OptionsParser<CommandLineOptions>().GetOptions();

            //
            // Setup layout
            //
            int[] columnLengths = new int[] { 25, 10, 45 };

            //
            // Write headings
            //
            Console.Write("Argument" + new string(' ', columnLengths[0] - "Argument".Length));
            Console.Write("Required" + new string(' ', columnLengths[1] - "Required".Length));
            Console.Write("Description" + new string(' ', columnLengths[2] - "Description".Length));
            Console.Write(new string('=', Console.WindowWidth));

            //
            // Write table
            //
            foreach (var option in options.OrderByDescending(o => o.IsRequired).ThenBy(o => o.Name))
            {
                string[] row = new string[]
                {
                   option.Name,
                   option.IsRequired ? "Y" : "N",
                   option.Description
                };

                for (int i = 0; i < row.Length; i++)
                {
                    //
                    // Write max width columns
                    //
                    while (row[i].Length > columnLengths[i])
                    {
                        int x = Console.CursorLeft;
                        Console.Write(row[i].Substring(0, columnLengths[i]));
                        row[i] = row[i].Substring(columnLengths[i]);
                        Console.CursorLeft = x;
                    }

                    //
                    // Write remainder
                    //
                    Console.Write(row[i]);
                    Console.Write(new string(' ', columnLengths[i] - row[i].Length));
                }

                Console.WriteLine();
            }
        }