コード例 #1
0
ファイル: psrsh.C プロジェクト: lbaehren/lofarsoft
void psrsh::add_options (CommandLine::Menu& menu)
{
  CommandLine::Argument* arg;

  arg = menu.add (this, &psrsh::interpreter_help, 'H');
  arg->set_long_name ("cmd");
  arg->set_help ("list available commands");
  arg->set_has_arg (optional_argument);

  arg = menu.add (load_files, 'n');
  arg->set_long_name ("nofiles");
  arg->set_help ("no filenames required");

  menu.set_help_footer
    ("\n"
     "If no files are specified, psrsh enters the interactive shell mode \n"
     "\n"
     "Otherwise, psrsh enters the shell script command processor mode: \n"
     "the first file must be the script, and all subseqent archive files \n"
     "will be processed using this script \n"
     + menu.get_help_footer ());
}
コード例 #2
0
ファイル: Application.C プロジェクト: lbaehren/lofarsoft
//! Parse the command line options
void Pulsar::Application::parse (int argc, char** argv)
{
  CommandLine::Menu menu;
  CommandLine::Argument* arg;

  menu.set_help_header
    ("\n" + name + " - " + description + "\n"
     "\n"
     "usage: " + name + " [options] filename[s] \n"
     "\n"
     "where options are:");

  if (has_manual) menu.set_help_footer
    ("\n" "See "PSRCHIVE_HTTP"/manuals/" + name + " for more details \n");

  menu.set_version (version);

  arg = menu.add (this, &Application::set_quiet, 'q');
  arg->set_help ("quiet mode");

  arg = menu.add (this, &Application::set_verbose, 'v');
  arg->set_help ("verbose mode");

  arg = menu.add (this, &Application::set_very_verbose, 'V');
  arg->set_help ("very verbose mode");

  arg = menu.add (metafile, 'M', "metafile");
  arg->set_help ("metafile contains list of archive filenames");

  arg = menu.add (Config::get_configuration(), &Config::set_filename,
		  "config", "file");
  arg->set_help ("configuration file");

  for (unsigned i=0; i<options.size(); i++)
    options[i]->add_options (menu);

  add_options (menu);

  menu.parse (argc, argv);

  dirglob_program = name;

  if ( stow_script && optind < argc )
  {
    script = argv[optind];
    optind ++;
  }

  if (!metafile.empty())
    stringfload (&filenames, metafile);
  else
  {
    for (int i=optind; i<argc; i++)
      dirglob (&filenames, argv[i]);

    if (sort_filenames)
      sort (filenames.begin(), filenames.end());
  }

  if (update_history)
  {
    string separator = " ";

    command += name + separator;

    for (int i=1; i<optind; i++)
      command += argv[i] + separator;

    if (command.length () > 80)
    {
      cerr << "WARNING: ProcHistory command string truncated to 80 characters"
	   << endl;
      command = command.substr (0, 80);
    }
  }
}