コード例 #1
0
ファイル: NumVars.C プロジェクト: AhmedAly83/moose
InputParameters validParams<NumVars>()
{
  InputParameters params = validParams<GeneralPostprocessor>();

  MooseEnum system_options("nonlinear auxiliary", "nonlinear");
  params.addParam<MooseEnum>("system", system_options, "The system for which you want to print the number of variables.");

  return params;
}
コード例 #2
0
ファイル: options.cpp プロジェクト: KN2C/rctools
/*!

*/
bool
Options::parseCmdLine( int argc,
                       char ** argv )
{
    rcsc::ParamMap system_options( "System Options" );
    rcsc::ParamMap window_options( "Window Options" );
    rcsc::ParamMap editor_options( "Editor Options" );
    rcsc::ParamMap view_options( "View Options" );

    bool help = false;
    bool version = false;

    system_options.add()
        ( "help", "h",
          rcsc::BoolSwitch( &help ),
          "print this message." )
        ( "version", "v",
          rcsc::BoolSwitch( &version ),
          "print version." )
        ;

    std::string geometry;

    window_options.add()
        ( "maximize", "",
          rcsc::BoolSwitch( &M_maximize ),
          "start with a maximized window." )
        ( "full-screen", "",
          rcsc::BoolSwitch( &M_full_screen ),
          "start with a full screen window." )
        ( "geometry", "",
          &geometry,
          "specifies the window geometry \"[WxH][+X+Y]\". e.g. --geometry=1024x768+0+0" )
        ;

    std::string conf_file;
    std::string data_file;
    std::string background_conf_file;

    editor_options.add()
        ( "conf", "c",
          &conf_file,
          "specifies a .conf file." )
        ( "data", "d",
          &data_file,
          "specifies a .dat file." )
        ( "background-conf", "C",
          &background_conf_file,
          "specifies a .conf file as a background data." )
        ( "auto-backup", "",
          &M_auto_backup,
          "make backup files automatically" )
        ;

    view_options.add()
        ( "no-antialiasing", "",
          rcsc::NegateSwitch( &M_antialiasing ),
          "disable antialiasing painting." )
        ( "no-auto-fit", "",
          rcsc::NegateSwitch( &M_auto_fit_mode ),
          "disable automatic view area fitting." )
        ;

    rcsc::CmdLineParser parser( argc, argv );

    parser.parse( system_options );
    parser.parse( window_options );
    parser.parse( editor_options );
    parser.parse( view_options );

    //
    // analyze positional options
    //

    for ( std::vector< std::string >::const_iterator it = parser.positionalOptions().begin();
          it != parser.positionalOptions().end();
          ++it )
    {
        // ".conf"
        if ( it->length() > 5
             && it->compare( it->length() - 5, 5, ".conf" ) == 0 )
        {
            if ( conf_file.empty() )
            {
                conf_file = *it;
            }
            else if ( background_conf_file.empty() )
            {
                background_conf_file = *it;
            }
            else // if ( ! conf_file.empty() && ! background_conf_file.empty() )
            {
                help = true;
                break;
            }
        }
        else
        {
            help = true;
            break;
        }
    }

    M_conf_file = QString::fromStdString( conf_file );
    M_data_file = QString::fromStdString( data_file );
    M_background_conf_file = QString::fromStdString( background_conf_file );

    //
    // help message
    //
    if ( help
         || parser.failed()
         || parser.positionalOptions().size() > 4 )
    {
        std::cout << "Usage: " << "fedit"
                  << " [options ... ] [conf file [background conf file]] [dat file]"
                  << std::endl;
        system_options.printHelp( std::cout, false ); // with_default = false
        window_options.printHelp( std::cout );
        editor_options.printHelp( std::cout );
        view_options.printHelp( std::cout );
        return false;
    }

    //
    // version message
    //
    if ( version )
    {
        std::cout << "fedit" << " Version " << VERSION
                  << std::endl;
        return false;
    }

    //
    // window size and position
    //

    parseWindowGeometry( geometry );

    return true;
}