Changeset 1629 for trunk/yat/utility


Ignore:
Timestamp:
Nov 17, 2008, 10:53:16 PM (13 years ago)
Author:
Peter
Message:

made help output more flexible

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/OptionArg.h

    r1602 r1629  
    5252       \brief Constructor
    5353       
    54        \param cmd Commandline Option is associated with
    55        \param name string such as "help" for --help, "h" for -h or
    56        "h,help" for having both short and long option name
    57        \param desc string used in help display
    58        \param required If true option must be found in commandline or
    59        exception is thrown in validation
     54       \param cmd Commandline Option is associated with \param name
     55       string such as "help" for --help, "h" for -h or "h,help" for
     56       having both short and long option name \param desc string used
     57       in help display \param required If true option must be found in
     58       commandline or exception is thrown in validation \param arg
     59       string to be used in help output such as `TARGET' in
     60       `--target=TARGET'. See print3().
    6061    */
    6162    OptionArg(CommandLine& cmd, std::string name, std::string desc,
    62               bool required=false)
    63       : Option(cmd, name, desc), required_(required) {}
     63              bool required=false, std::string arg="")
     64      : Option(cmd, name, desc), print_arg_(arg), required_(required) {}
    6465
    6566    /**
     
    8384
    8485  private:
     86    std::string print_arg_;
    8587    bool required_;
    8688    T value_;
     
    155157
    156158    virtual void do_validate2(void) const {}
     159
     160    virtual std::string print3(void) const
     161    {
     162      if (print_arg_.empty())
     163        return std::string("");
     164      return std::string("=")+print_arg_;
     165    }
     166
    157167  };
    158168
Note: See TracChangeset for help on using the changeset viewer.