diff options
author | Baruch Sterin <baruchs@gmail.com> | 2013-12-07 00:44:57 -0800 |
---|---|---|
committer | Baruch Sterin <baruchs@gmail.com> | 2013-12-07 00:44:57 -0800 |
commit | c5a0ce906377b51ef2eab9fcdd3cc8c56de43ef3 (patch) | |
tree | 72695d32429ec7bad5afc2cf8c64bddafe6fe431 /src/base | |
parent | 22f9e9998f9395c684beb390cd3ec600d10039aa (diff) | |
download | abc-c5a0ce906377b51ef2eab9fcdd3cc8c56de43ef3.tar.gz abc-c5a0ce906377b51ef2eab9fcdd3cc8c56de43ef3.tar.bz2 abc-c5a0ce906377b51ef2eab9fcdd3cc8c56de43ef3.zip |
add a new command line option to ABC, -q, same as -c, but without echoing the command
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/main/main.c | 42 | ||||
-rw-r--r-- | src/base/main/mainUtils.c | 2 |
2 files changed, 29 insertions, 15 deletions
diff --git a/src/base/main/main.c b/src/base/main/main.c index 1ef79b73..e6d93c1a 100644 --- a/src/base/main/main.c +++ b/src/base/main/main.c @@ -89,7 +89,14 @@ int Abc_RealMain( int argc, char * argv[] ) const char * sOutFile, * sInFile; char * sCommand; 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 // watch for {,,msvcrtd.dll}*__p__crtBreakAlloc() @@ -127,7 +134,7 @@ int Abc_RealMain( int argc, char * argv[] ) #endif /* ABC_PYTHON_EMBED */ // default options - fBatch = 0; + fBatch = INTERACTIVE; fInitSource = 1; fInitRead = 0; fFinalWrite = 0; @@ -136,26 +143,31 @@ int Abc_RealMain( int argc, char * argv[] ) sprintf( sWriteCmd, "write" ); 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) { case 'c': strcpy( sCommandUsr, globalUtilOptarg ); - fBatch = 1; + fBatch = BATCH; + break; + + case 'q': + strcpy( sCommandUsr, globalUtilOptarg ); + fBatch = BATCH_QUIET; break; case 'C': strcpy( sCommandUsr, globalUtilOptarg ); - fBatch = 2; + fBatch = BATCH_THEN_INTERACTIVE; break; case 'f': sprintf(sCommandUsr, "source %s", globalUtilOptarg); - fBatch = 1; + fBatch = BATCH; break; case 'F': sprintf(sCommandUsr, "source -x %s", globalUtilOptarg); - fBatch = 1; + fBatch = BATCH; break; case 'h': @@ -183,7 +195,7 @@ int Abc_RealMain( int argc, char * argv[] ) else { goto usage; } - fBatch = 1; + fBatch = BATCH; break; case 'T': @@ -198,13 +210,13 @@ int Abc_RealMain( int argc, char * argv[] ) else { goto usage; } - fBatch = 1; + fBatch = BATCH; break; case 'x': fFinalWrite = 0; fInitRead = 0; - fBatch = 1; + fBatch = BATCH; break; case 'b': @@ -221,10 +233,10 @@ int Abc_RealMain( int argc, char * argv[] ) extern Gia_Man_t * Gia_ManFromBridge( FILE * pFile, Vec_Int_t ** pvInit ); 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 ); - if ( fBatch ) + if ( fBatch!=INTERACTIVE ) { pAbc->fBatchMode = 1; @@ -267,14 +279,14 @@ int Abc_RealMain( int argc, char * argv[] ) } } - if (fBatch == 2){ - fBatch = 0; + if (fBatch == BATCH_THEN_INTERACTIVE){ + fBatch = INTERACTIVE; pAbc->fBatchMode = 0; } } - if ( !fBatch ) + if ( fBatch==INTERACTIVE ) { // start interactive mode diff --git a/src/base/main/mainUtils.c b/src/base/main/mainUtils.c index 2b4e682b..30d1693c 100644 --- a/src/base/main/mainUtils.c +++ b/src/base/main/mainUtils.c @@ -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", ProgName); 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\n"); fprintf( pAbc->Err, " -h\t\tprint the command usage\n"); |