Esempio n. 1
0
void
CommandObject::GetArgumentHelp (Stream &str, CommandArgumentType arg_type, CommandInterpreter &interpreter)
{
    const ArgumentTableEntry* table = CommandObject::GetArgumentTable();
    ArgumentTableEntry *entry = (ArgumentTableEntry *) &(table[arg_type]);
    
    // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up...

    if (entry->arg_type != arg_type)
        entry = CommandObject::FindArgumentDataByType (arg_type);

    if (!entry)
        return;

    StreamString name_str;
    name_str.Printf ("<%s>", entry->arg_name);

    if (entry->help_function)
    {
        const char* help_text = entry->help_function();
        if (!entry->help_function.self_formatting)
        {
            interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", help_text,
                                                 name_str.GetSize());
        }
        else
        {
            interpreter.OutputHelpText(str, name_str.GetData(), "--", help_text,
                                       name_str.GetSize());
        }
    }
    else
        interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", entry->help_text, name_str.GetSize());
}
Esempio n. 2
0
void
Property::DumpDescription (CommandInterpreter &interpreter,
                           Stream &strm,
                           uint32_t output_width,
                           bool display_qualified_name) const
{
    if (m_value_sp)
    {
        const char *desc = GetDescription();

        if (desc)
        {
            StreamString qualified_name;
            const OptionValueProperties *sub_properties = m_value_sp->GetAsProperties();
            if (sub_properties)
            {
                strm.EOL();
                
                if (m_value_sp->DumpQualifiedName(qualified_name))
                    strm.Printf("'%s' variables:\n\n", qualified_name.GetString().c_str());
                sub_properties->DumpAllDescriptions(interpreter, strm);
            }
            else
            {
                if (desc)
                {
                    if (display_qualified_name)
                    {
                        StreamString qualified_name;
                        DumpQualifiedName(qualified_name);
                        interpreter.OutputFormattedHelpText (strm,
                                                             qualified_name.GetString().c_str(),
                                                             "--",
                                                             desc,
                                                             output_width);
                    }
                    else
                    {
                        interpreter.OutputFormattedHelpText (strm,
                                                             m_name.GetCString(),
                                                             "--",
                                                             desc,
                                                             output_width);
                    }
                }
            }
        }
    }
}