Ejemplo n.º 1
0
    // Prints out short options with a leading '-' and long ones with '--'.
    // Puts a ',' between them if it has both.
 string CommandOption::getFullOptionString() const
 {
    string toReturn("  ");
    if (shortOpt != 0)
    {
       toReturn += string("-") + string(1, shortOpt);
       if (!longOpt.empty())
       {
          toReturn += string(", --") + longOpt;
          if (optFlag == hasArgument)
             toReturn += "=" + getArgString();
       }
       else
       {
          if (optFlag == hasArgument)
             toReturn += "  " + getArgString();
       }
    }
    else
    {
       toReturn += string("    --") + longOpt;
       if (optFlag == hasArgument)
          toReturn += "=" + getArgString();
    }
    return toReturn;
 }
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
// 描述: 处理标准命令行参数
// 参数:
//   isInitializing - 应用程序 (IseApplication) 是否处于初始化期间
// 返回:
//   true  - 当前命令行参数是标准参数
//   false - 与上相反
//-----------------------------------------------------------------------------
bool IseApplication::processStandardArgs(bool isInitializing)
{
    if (!isInitializing)
    {
        if (getArgCount() == 1)
        {
            string arg = getArgString(0);
            if (arg == "--version")
            {
                string version = iseBusiness_->getAppVersion();
                printf("%s\n", version.c_str());
                return true;
            }
            if (arg == "--help")
            {
                string help = iseBusiness_->getAppHelp();
                printf("%s\n", help.c_str());
                return true;
            }
        }
    }
    else
    {
        if (argList_.exists("--nodaemon"))
        {
            iseOptions_.setIsDaemon(false);
            return true;
        }
    }

    return false;
}
Ejemplo n.º 3
0
    // returns a string like this:
    //
    //   -f | --foo  <arg>
    //        this is the description
    //
 std::string CommandOption::getDescription() const
 {
    ostringstream out;
       // do the option itself first
    out << '\t';
    if (shortOpt != 0)
    {
       out << '-' << shortOpt;
       if (!longOpt.empty())
          out << " | ";
       else
          out << '\t';        
    }
    if (! longOpt.empty())
    {
       out << "--" << longOpt;
    }
    if (optFlag == hasArgument)
    {
       out << " " << getArgString();
    }
       // and the description goes on a new line
    out << endl << prettyPrint(description, 
                               "\n",
                               "                  ", 
                               "               ");
    if (maxCount != 0)
    {
       out << "\t\tUp to " << maxCount << " may be used on the command line."
           << endl;
    }
    return out.str();
 }
Ejemplo n.º 4
0
std::string
CZ80OpData::
getOpString(ushort pc)
{
  std::string str = op->getName();

  ushort len1 = str.size();

  if (op->type1 != 0) {
    for ( ; len1 < 5; ++len1)
      str += " ";

    str += getArgString(pc, op->type1, op->arg1, values1, num_values1);

    if (op->type2 != 0) {
      str += ", ";

      str += getArgString(pc, op->type2, op->arg2, values2, num_values2);
    }
  }

  return str;
}