예제 #1
0
 /** set up an options parser to use the application commandline.
  *  Recognises the following options
  *  \code
  *  --help
  *  [--session] FILENAME
  *  --script FILENAME
  *  --headless
  *  --port #
  *  \endcode
  *  @todo describe the actual options
  */
 Option::Option (lib::Cmdline& cmdline)
   : syntax("Lumiera, the non linear video editor.\nSupported parameters"),
     parameters()
   {
     syntax.add_options()
       ("help,h",      "produce help message")
       ("session,f",   op::value<string>(),
                       "session file to load (UNIMPLEMENTED)")
       ("script,s",    op::value<VectS>(),
                       "execute the given script (UNIMPLEMENTED)")
       ("headless",    op::bool_switch(),
                       "start without GUI")
       ("port,p",      op::value<int>(),
                       "open renderfarm node at given port (UNIMPLEMENTED)")
       ("define,def,D",op::value<VectS>(),
                       "enter definition into config system (UNIMPLEMENTED)")
       ;
     
     // the name of an session file to open...
     op::positional_options_description posopt;
     posopt.add("session", 1);   // ... can be given as 1st positional parameter
     
     op::parsed_options parsed = 
       op::command_line_parser (cmdline)
         .options (syntax)
         .positional(posopt)
         .allow_unregistered()
         .run();  
     
     op::store (parsed, parameters);
     op::notify(parameters);   
     
     // remove all recognised options from original cmdline vector
     cmdline = op::collect_unrecognized(parsed.options, op::include_positional);
     
     if (isHelp())
       {
         cerr << *this;
         exit(-1);
       }
     if (isConfigDefs())
       {
         UNIMPLEMENTED ("feed definitions from commandline to Config system");
       }
   }
예제 #2
0
파일: tddAttempt.c 프로젝트: jonmann20/C
int is2(int (*funcPtr)(int, int), int a, int b, int x, char* name){
	return isHelp(((*funcPtr)(a, b) == x), name);
}
예제 #3
0
파일: tddAttempt.c 프로젝트: jonmann20/C
int is1(int (*funcPtr)(int), int a, int x, char* name){
	return isHelp(((*funcPtr)(a) == x), name);
}
예제 #4
0
int main( int argc, const char* argv[] ) {

	int result;
	int i = 1; // pq el parametro 0 es el ejecutable
	char* listBytes;
	char* listFields;

//	//esto no va, es para probar
//	parseList( argv[i], TYPE_BYTES);


	// itero el vector de parametros
	while( i<argc ){

		if( isVersion( argv[i] ) == 1 ){
			_isVersion = 1;
		} else if( isHelp(argv[i]) == 1 ){
			_isHelp = 1;
		} else if( isBytes(argv[i]) == 1 ){
			_isBytes = 1;
			// Parsear el argv[i+1] y determinar los elementos o rangos
			i++;
			listBytes = parseList( argv[i], TYPE_BYTES);
		} else if( isFields(argv[i]) == 1){
			_isFields = 1;
			// Parsear el argv[i+1] y determinar los elementos o rangos
			i++;
			listFields = parseList( argv[i], TYPE_FIELDS);
		} else if( isDelimiter(argv[i]) == 1 ){
			_isDelimiter = 1;
			// Parsear el argv[i+1] y determinar el delimitador
			i++;
			_delimiter = argv[i][0];	// el delimitador es de solo un caracter. Si tiene mas de uno se toma el primero
		} else if( isIgnore(argv[i]) == 1 ){
			_isIgnore = 1;

		} else{
			// argumento invalido!!!
			_hasInvalidParameters = 1;
			_invalidParameter = argv[i];
		}
		i++;
	}
//	puts(listBytes);
//	puts(listFields);
	if (_isFields==1){
		//Imprimir lo que corresponda
		imprimir(listFields, TYPE_FIELDS);
	}
	if (_isBytes==1){
		//Imprimir lo que corresponda
		imprimir(listBytes, TYPE_BYTES);
	}

	// Sino tiene parametros invalidos, sigo
	if( _hasInvalidParameters == 0 ){
		// ahora me fijo q operacion hay q hacer
		if( _isVersion == 1 ){
			// imprimo version y salgo
			puts("Imprimo Version!!");
		} else if(_isHelp==1){
			// imprimo help y salgo
			puts("Imprimo help!!");
		} else if(_isBytes==1){
			// hago la operacion del CUT segun el conjunto de bytes previamente parseado
			// y salgo
		} else if(_isFields==1){
			// hago la operacion del CUT (usando el delimitador seteado o default y el parametro ignore)
			// con el conjunto de fields previamente parseado y devuelvo el resultado por stdout
			// y salgo
		}
		result = EXIT_SUCCESS;
		puts("saliendo bien");
	} else {
		// si tiene parametros invalidos salgo
		result = EXIT_FAILURE;
		puts( "saliendo mal" );
	}

	puts("saliendo "); /* prints TP 0 */
//	puts(result);
	return result;
}