From 5df0cf98e619d64d110e17ab4e31a986257f47a6 Mon Sep 17 00:00:00 2001 From: Baruch Sterin Date: Wed, 18 Nov 2015 16:32:39 -0800 Subject: main: add option -Q for execute command quietly, then interactive --- src/base/main/mainReal.c | 18 +++++++++++++----- src/base/main/mainUtils.c | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'src/base/main') diff --git a/src/base/main/mainReal.c b/src/base/main/mainReal.c index a26cfa84..ee43d38d 100644 --- a/src/base/main/mainReal.c +++ b/src/base/main/mainReal.c @@ -89,6 +89,7 @@ int Abc_RealMain( int argc, char * argv[] ) 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 + BATCH_QUIET_THEN_INTERACTIVE, // as in batch then interactive mode, but don't echo the command BATCH_SMT // special batch mode, which expends SMTLIB problem via stdin } fBatch; @@ -114,7 +115,7 @@ int Abc_RealMain( int argc, char * argv[] ) sprintf( sWriteCmd, "write" ); Extra_UtilGetoptReset(); - while ((c = Extra_UtilGetopt(argc, argv, "c:q:C:S:hf:F:o:st:T:xb")) != EOF) { + while ((c = Extra_UtilGetopt(argc, argv, "c:q:C:Q:S:hf:F:o:st:T:xb")) != EOF) { switch(c) { case 'c': if( Vec_StrSize(sCommandUsr) > 0 ) @@ -134,6 +135,15 @@ int Abc_RealMain( int argc, char * argv[] ) fBatch = BATCH_QUIET; break; + case 'Q': + if( Vec_StrSize(sCommandUsr) > 0 ) + { + Vec_StrAppend(sCommandUsr, " ; "); + } + Vec_StrAppend(sCommandUsr, globalUtilOptarg ); + fBatch = BATCH_QUIET_THEN_INTERACTIVE; + break; + case 'C': if( Vec_StrSize(sCommandUsr) > 0 ) { @@ -242,14 +252,13 @@ 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!=INTERACTIVE && fBatch!=BATCH_QUIET && Vec_StrSize(sCommandUsr)>0 ) + else if ( fBatch!=INTERACTIVE && fBatch!=BATCH_QUIET && fBatch!=BATCH_QUIET_THEN_INTERACTIVE && Vec_StrSize(sCommandUsr)>0 ) Abc_Print( 1, "ABC command line: \"%s\".\n\n", Vec_StrArray(sCommandUsr) ); if ( fBatch!=INTERACTIVE ) { pAbc->fBatchMode = 1; - if (argc - globalUtilOptind == 0) { sInFile = NULL; @@ -288,7 +297,7 @@ int Abc_RealMain( int argc, char * argv[] ) } } - if (fBatch == BATCH_THEN_INTERACTIVE){ + if (fBatch == BATCH_THEN_INTERACTIVE || fBatch == BATCH_QUIET_THEN_INTERACTIVE){ fBatch = INTERACTIVE; pAbc->fBatchMode = 0; } @@ -375,4 +384,3 @@ static int TypeCheck( Abc_Frame_t * pAbc, const char * s ) ABC_NAMESPACE_IMPL_END - diff --git a/src/base/main/mainUtils.c b/src/base/main/mainUtils.c index c0145641..d1fe1d20 100644 --- a/src/base/main/mainUtils.c +++ b/src/base/main/mainUtils.c @@ -121,11 +121,12 @@ void Abc_UtilsPrintUsage( Abc_Frame_t * pAbc, char * ProgName ) { fprintf( pAbc->Err, "\n" ); fprintf( pAbc->Err, - "usage: %s [-c cmd] [-f script] [-h] [-o file] [-s] [-t type] [-T type] [-x] [-b] [file]\n", + "usage: %s [-c cmd] [-q cmd] [-C cmd] [-Q 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, " -Q cmd\texecute commands `cmd' quietly, 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"); @@ -291,4 +292,3 @@ char * DateReadFromDateString( char * datestr ) ABC_NAMESPACE_IMPL_END - -- cgit v1.2.3