Exemplo n.º 1
0
        public static IColorConsole WriteHelp(this IColorConsole con, ClassDefinition cd)
        {
            foreach (var method in cd.IncludedMethods)
            {
                con.w(ExeColor, "{0}", cd.ExeName).w(CommandColor, " {0}", method.Command);
                foreach (var group in method.Parameters.GroupBy(p => !p.HasDefaultValue))
                {
                    bool optionals = group.Key;
                    foreach (var parameter in group)
                    {
                        con.WriteShortHelp(parameter);
                    }
                }
                con.wl();
            }

            if (cd.CommonParameters.Length > 0)
            {
                con.w("Common parameters:");
                foreach (var parameter in cd.CommonParameters)
                {
                    con.WriteShortHelp(parameter);
                }
                con.wl();
            }
            return(con);
        }
Exemplo n.º 2
0
        public static IColorConsole WriteHelp(this IColorConsole con, ClassDefinition cd, string command)
        {
            var methods = cd.FindMethods(command);

            if (methods.Length == 0)
            {
                con.w("Help for ").w(ConsoleColor.Red, "{0}", command).wl(" not found");
            }
            else
            {
                char argStartsWith    = cd.Config.ArgStartsWith;
                char argSeparator     = cd.Config.ArgSeparator;
                char argListSeparator = cd.Config.ArgListSeparator;
                foreach (var method in methods)
                {
                    con.w(ExeColor, "{0}", cd.ExeName);
                    con.w(CommandColor, " {0}", method.Command);
                    foreach (var group in method.Parameters.GroupBy(p => !p.HasDefaultValue))
                    {
                        bool optionals = group.Key;
                        foreach (var parameter in group)
                        {
                            con.WriteShortHelp(parameter);
                        }
                    }
                    con.wl();
                    if (method.HelpText != null)
                    {
                        con.w(Indent).wl("{0}", method.HelpText);
                    }
                    foreach (var group in method.Parameters.GroupBy(p => !p.HasDefaultValue))
                    {
                        bool optionals = group.Key;
                        foreach (var parameter in group)
                        {
                            con.WriteHelp(parameter);
                        }
                    }
                    //con.wl();
                }
            }
            if (cd.CommonParameters.Length > 0)
            {
                con.wl("Common parameters:");
                foreach (var parameter in cd.CommonParameters)
                {
                    con.WriteHelp(parameter);
                }
            }
            return(con);
        }