Commit c5a0ce90 by Baruch Sterin

add a new command line option to ABC, -q, same as -c, but without echoing the command

parent 22f9e999
...@@ -89,7 +89,14 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -89,7 +89,14 @@ int Abc_RealMain( int argc, char * argv[] )
const char * sOutFile, * sInFile; const char * sOutFile, * sInFile;
char * sCommand; char * sCommand;
int fStatus = 0; int fStatus = 0;
int c, fBatch, fInitSource, fInitRead, fFinalWrite; int c, fInitSource, fInitRead, fFinalWrite;
enum {
INTERACTIVE, // interactive mode
BATCH, // batch mode, run a command and quit
BATCH_THEN_INTERACTIVE, // run a command, then back to interactive mode
BATCH_QUIET // as in batch mode, but don't echo the command
} fBatch;
// added to detect memory leaks // added to detect memory leaks
// watch for {,,msvcrtd.dll}*__p__crtBreakAlloc() // watch for {,,msvcrtd.dll}*__p__crtBreakAlloc()
...@@ -127,7 +134,7 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -127,7 +134,7 @@ int Abc_RealMain( int argc, char * argv[] )
#endif /* ABC_PYTHON_EMBED */ #endif /* ABC_PYTHON_EMBED */
// default options // default options
fBatch = 0; fBatch = INTERACTIVE;
fInitSource = 1; fInitSource = 1;
fInitRead = 0; fInitRead = 0;
fFinalWrite = 0; fFinalWrite = 0;
...@@ -136,26 +143,31 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -136,26 +143,31 @@ int Abc_RealMain( int argc, char * argv[] )
sprintf( sWriteCmd, "write" ); sprintf( sWriteCmd, "write" );
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ((c = Extra_UtilGetopt(argc, argv, "c:C:hf:F:o:st:T:xb")) != EOF) { while ((c = Extra_UtilGetopt(argc, argv, "c:q:C:hf:F:o:st:T:xb")) != EOF) {
switch(c) { switch(c) {
case 'c': case 'c':
strcpy( sCommandUsr, globalUtilOptarg ); strcpy( sCommandUsr, globalUtilOptarg );
fBatch = 1; fBatch = BATCH;
break;
case 'q':
strcpy( sCommandUsr, globalUtilOptarg );
fBatch = BATCH_QUIET;
break; break;
case 'C': case 'C':
strcpy( sCommandUsr, globalUtilOptarg ); strcpy( sCommandUsr, globalUtilOptarg );
fBatch = 2; fBatch = BATCH_THEN_INTERACTIVE;
break; break;
case 'f': case 'f':
sprintf(sCommandUsr, "source %s", globalUtilOptarg); sprintf(sCommandUsr, "source %s", globalUtilOptarg);
fBatch = 1; fBatch = BATCH;
break; break;
case 'F': case 'F':
sprintf(sCommandUsr, "source -x %s", globalUtilOptarg); sprintf(sCommandUsr, "source -x %s", globalUtilOptarg);
fBatch = 1; fBatch = BATCH;
break; break;
case 'h': case 'h':
...@@ -183,7 +195,7 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -183,7 +195,7 @@ int Abc_RealMain( int argc, char * argv[] )
else { else {
goto usage; goto usage;
} }
fBatch = 1; fBatch = BATCH;
break; break;
case 'T': case 'T':
...@@ -198,13 +210,13 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -198,13 +210,13 @@ int Abc_RealMain( int argc, char * argv[] )
else { else {
goto usage; goto usage;
} }
fBatch = 1; fBatch = BATCH;
break; break;
case 'x': case 'x':
fFinalWrite = 0; fFinalWrite = 0;
fInitRead = 0; fInitRead = 0;
fBatch = 1; fBatch = BATCH;
break; break;
case 'b': case 'b':
...@@ -221,10 +233,10 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -221,10 +233,10 @@ int Abc_RealMain( int argc, char * argv[] )
extern Gia_Man_t * Gia_ManFromBridge( FILE * pFile, Vec_Int_t ** pvInit ); extern Gia_Man_t * Gia_ManFromBridge( FILE * pFile, Vec_Int_t ** pvInit );
pAbc->pGia = Gia_ManFromBridge( stdin, NULL ); pAbc->pGia = Gia_ManFromBridge( stdin, NULL );
} }
else if ( fBatch && sCommandUsr[0] ) else if ( fBatch!=INTERACTIVE && fBatch!=BATCH_QUIET && sCommandUsr[0] )
Abc_Print( 1, "ABC command line: \"%s\".\n\n", sCommandUsr ); Abc_Print( 1, "ABC command line: \"%s\".\n\n", sCommandUsr );
if ( fBatch ) if ( fBatch!=INTERACTIVE )
{ {
pAbc->fBatchMode = 1; pAbc->fBatchMode = 1;
...@@ -267,14 +279,14 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -267,14 +279,14 @@ int Abc_RealMain( int argc, char * argv[] )
} }
} }
if (fBatch == 2){ if (fBatch == BATCH_THEN_INTERACTIVE){
fBatch = 0; fBatch = INTERACTIVE;
pAbc->fBatchMode = 0; pAbc->fBatchMode = 0;
} }
} }
if ( !fBatch ) if ( fBatch==INTERACTIVE )
{ {
// start interactive mode // start interactive mode
......
...@@ -124,6 +124,8 @@ void Abc_UtilsPrintUsage( Abc_Frame_t * pAbc, char * ProgName ) ...@@ -124,6 +124,8 @@ void Abc_UtilsPrintUsage( Abc_Frame_t * pAbc, char * ProgName )
"usage: %s [-c cmd] [-f script] [-h] [-o file] [-s] [-t type] [-T type] [-x] [-b] [file]\n", "usage: %s [-c cmd] [-f script] [-h] [-o file] [-s] [-t type] [-T type] [-x] [-b] [file]\n",
ProgName); ProgName);
fprintf( pAbc->Err, " -c cmd\texecute commands `cmd'\n"); fprintf( pAbc->Err, " -c cmd\texecute commands `cmd'\n");
fprintf( pAbc->Err, " -q cmd\texecute commands `cmd' quietly\n");
fprintf( pAbc->Err, " -C cmd\texecute commands `cmd', then continue in interactive mode\n");
fprintf( pAbc->Err, " -F script\texecute commands from a script file and echo commands\n"); fprintf( pAbc->Err, " -F script\texecute commands from a script file and echo commands\n");
fprintf( pAbc->Err, " -f script\texecute commands from a script file\n"); fprintf( pAbc->Err, " -f script\texecute commands from a script file\n");
fprintf( pAbc->Err, " -h\t\tprint the command usage\n"); fprintf( pAbc->Err, " -h\t\tprint the command usage\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment