Пример #1
0
bool osDoArgs(pvoid handler, pfnDoArgsCB pFunc)
{
    osAssert(handler && pFunc);
    CSimpleOpt * pArgs = ((CmdOptHandle *)handler)->pArgs;
    char * pArgStr = pArgs->OptionArg();

    pFunc(pArgs->OptionId(), pArgs->OptionText(), pArgs->OptionArg());
    return true;
}
Пример #2
0
bool processArgs(CSimpleOpt &s)
{
   bool rc = false;

   while (s.Next())
   {
      if (s.LastError() != SO_SUCCESS)
      {
         std::cout << s.GetLastErrorText(s.LastError()) << ": '" << s.OptionText() 
                   << "' (use -h to get command line help)" << std::endl;
         help();
         return false; 
      }

      Vector<String> splits;

      switch (s.OptionId())
      {
         case SET_PROFILE:
	    setProfile = true;
            profileName = s.OptionArg();
            break;

         case SHOW_GUI:
            showGUI = true; 
            break;

         default:
	    help();
 	    break;
      };
   }

   return true;
}
Пример #3
0
bool osDoMultiArgs(pvoid handler, int  nMultiArgs, pfnDoMultiArgsCB pFunc)
{
    osAssert(handler && pFunc);
    CSimpleOpt * pArgs = ((CmdOptHandle *)handler)->pArgs;
    TCHAR ** rgpszArg = NULL;

    // get the number of arguments if necessary
    if (nMultiArgs == -1) 
    {
        // first arg is a count of how many we have
        rgpszArg = pArgs->MultiArg(1);
        if (!rgpszArg)
        {
            osPrintf( _T("%s: '%s' (use --help to get command line help)\n"),
                GetLastErrorText(pArgs->LastError()), pArgs->OptionText());
            return false;
        }

        nMultiArgs = _ttoi(rgpszArg[0]);
    }

    // get the arguments to follow
    rgpszArg = pArgs->MultiArg(nMultiArgs);
    if (!rgpszArg)
    {
        osPrintf( _T("%s: '%s' (use --help to get command line help)\n"),
            GetLastErrorText(pArgs->LastError()), pArgs->OptionText());
        return false;
    }

    for (int n = 0; n < nMultiArgs; ++n)
    {
        pFunc(pArgs->OptionId(), pArgs->OptionText(), n, rgpszArg[n]);
    }

    return true;
}
Пример #4
0
bool osGetOpt(pvoid handler, int * pID, bool * pErr)
{
    osAssert(handler && pID);
    CSimpleOpt * pArgs = ((CmdOptHandle *)handler)->pArgs;
    bool ret = pArgs->Next();
    if (!ret) return ret;

    *pID = pArgs->OptionId();
    *pErr = false;
    if (pArgs->LastError() != SO_SUCCESS)
    {
        osPrintf( _T("%s: '%s' (use --help to get command line help)\n"),
            GetLastErrorText(pArgs->LastError()), pArgs->OptionText());
        *pErr = true;
    }

    return ret;
}
Пример #5
0
static void 
DoMultiArgs(
    CSimpleOpt &    args, 
    int             nMultiArgs
    )
{
    TCHAR ** rgpszArg = NULL;

    // get the number of arguments if necessary
    if (nMultiArgs == -1) {
        // first arg is a count of how many we have
        rgpszArg = args.MultiArg(1);
        if (!rgpszArg) {
            _tprintf(
                _T("%s: '%s' (use --help to get command line help)\n"),
                GetLastErrorText(args.LastError()), args.OptionText());
            return;
        }

        nMultiArgs = _ttoi(rgpszArg[0]);
    }
    _tprintf(_T("%s: expecting %d args\n"), args.OptionText(), nMultiArgs);

    // get the arguments to follow
    rgpszArg = args.MultiArg(nMultiArgs);
    if (!rgpszArg) {
        _tprintf(
            _T("%s: '%s' (use --help to get command line help)\n"),
            GetLastErrorText(args.LastError()), args.OptionText());
        return;
    }

    for (int n = 0; n < nMultiArgs; ++n) {
        _tprintf(_T("MultiArg %d: %s\n"), n, rgpszArg[n]);
    }
}
Пример #6
0
void osOptArgsStop(pvoid handler)
{
    CSimpleOpt * pArgs = ((CmdOptHandle *)handler)->pArgs;
    pArgs->Stop();
}