Example #1
0
        private static void DisplayAvailableCommands(CMenuItem menu, bool inner)
        {
            if (menu == null)
            {
                throw new ArgumentNullException("menu");
            }

            if (!inner)
            {
                Console.WriteLine("Available commands:");
            }
            var abbreviations = menu.CommandAbbreviations().OrderBy(it => it.Key);

            foreach (var ab in abbreviations)
            {
                if (ab.Value == null)
                {
                    Console.Write("      ");
                }
                else
                {
                    Console.Write(ab.Value.PadRight(3) + " | ");
                }
                Console.WriteLine(ab.Key);
            }
            if (!inner)
            {
                Console.WriteLine("Type \"help <command>\" for individual command help.");
            }
        }
Example #2
0
        private void DisplayAvailableCommands(CMenuItem menu, bool inner)
        {
            if (menu == null)
            {
                throw new ArgumentNullException("menu");
            }

            if (!inner)
            {
                OnWriteLine("Available commands:");
            }
            var abbreviations = menu
                                .CommandAbbreviations()
                                .OrderBy(it => it.Key)
                                .ToArray();
            var longestAbbreviation = abbreviations.Max(a => a.Value?.Length) ?? 0;

            foreach (var ab in abbreviations)
            {
                if (ab.Value == null)
                {
                    OnWrite(new string (' ', longestAbbreviation + 3));
                }
                else
                {
                    OnWrite(ab.Value.PadRight(longestAbbreviation) + " | ");
                }
                OnWriteLine(ab.Key);
            }
            if (!inner)
            {
                OnWriteLine("Type \"help <command>\" for individual command help.");
            }
        }
Example #3
0
        private void DisplayAvailableCommands(CMenuItem menu, bool inner)
        {
            if (menu == null) {
                throw new ArgumentNullException ("menu");
            }

            if (!inner) {
                OnWriteLine ("Available commands:");
            }
            var abbreviations = menu.CommandAbbreviations ().OrderBy (it => it.Key);
            foreach (var ab in abbreviations) {
                if (ab.Value == null) {
                    OnWrite ("      ");
                }
                else {
                    OnWrite (ab.Value.PadRight (3) + " | ");
                }
                OnWriteLine (ab.Key);
            }
            if (!inner) {
                OnWriteLine ("Type \"help <command>\" for individual command help.");
            }
        }