Changeset 982 for trunk/yat


Ignore:
Timestamp:
Oct 22, 2007, 5:26:04 PM (14 years ago)
Author:
Peter
Message:

adding description variable for cmd

Location:
trunk/yat/utility
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/CommandLine.cc

    r981 r982  
    4242namespace utility {
    4343
    44   CommandLine::CommandLine(void)
     44  CommandLine::CommandLine(std::string str)
     45    : description_(str)
    4546  {}
    4647
     
    171172  std::ostream& operator<<(std::ostream& os, const CommandLine& cmd)
    172173  {
     174    os << cmd.description_ << "\n";
    173175    ColumnStream cs2(os, 2);
    174176    std::string::size_type width = 0;
  • trunk/yat/utility/CommandLine.h

    r981 r982  
    5555     CommandLine cmd;
    5656     OptionArg<std::string> dir(cmd, "d,dir", "output directory");
    57      OptionSwitch help(cmd, "h,help", "display this help and exit");
     57     OptionHelp help(cmd);
    5858     OptionSwitch target(cmd, "T,target", "treat DEST as a normal file", true);
    5959     OptionSwitch verbose(cmd, "v,verbose", "explain what is being done");
     
    6666       return 1;
    6767     } 
    68      if (help.present()){
    69        std::cout << "Usage: " << cmd.program_name() << " [OPTION]...\n\n"
    70                  << "This is a test\n\n" << cmd << "\n"
    71                  << "Report bugs to peter@example.net\n";
    72        exit(0);
    73      }
    7468     if (version.present()){
    7569       std::cout << cmd.program_name() << " 1.0\n"
    7670                 << "Copyright (C) 2007 Peter Johansson\n\n"
    77                  << "This is free softwarel see the source for copying "
     71                 << "This is free software see the source for copying "
    7872                 << "conditions. There is NO\nwarranty; not even for "
    7973                 << "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
     
    10094    /**
    10195       \brief deafult constructor
     96
     97       \param str text preceeding the list of option in output
    10298    */
    103     CommandLine(void);
     99    CommandLine(std::string str="Available options are:");
    104100
    105101    /**
     
    139135    std::vector<std::string> split(std::string str, char del) const;
    140136
     137    std::string description_;
    141138    std::vector<Option*> options_;
    142139    std::map<char, Option*> short_options_;
  • trunk/yat/utility/OptionHelp.cc

    r981 r982  
    3838  {
    3939    usage_ = std::string("Usage: ")+cmd.program_name()+
    40       std::string(" [OPTION]...\n\n");
     40      std::string(" [OPTION]...\n");
    4141  }
    4242
     
    4545                               std::vector<std::string>::iterator last)
    4646  {
    47     std::cout << usage_ << synopsis_;
    48     std::cout << cmd();
     47    std::cout << usage_ << "\n" << synopsis_ << "\n";
     48    std::cout << cmd() << "\n";
    4949    std::cout << post_cmd_;
    5050    exit(0);
Note: See TracChangeset for help on using the changeset viewer.