Commit 5df0cf98 by Baruch Sterin

main: add option -Q for execute command quietly, then interactive

parent 2ac47fe5
...@@ -89,6 +89,7 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -89,6 +89,7 @@ int Abc_RealMain( int argc, char * argv[] )
BATCH, // batch mode, run a command and quit BATCH, // batch mode, run a command and quit
BATCH_THEN_INTERACTIVE, // run a command, then back to interactive mode 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, // 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 BATCH_SMT // special batch mode, which expends SMTLIB problem via stdin
} fBatch; } fBatch;
...@@ -114,7 +115,7 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -114,7 +115,7 @@ int Abc_RealMain( int argc, char * argv[] )
sprintf( sWriteCmd, "write" ); sprintf( sWriteCmd, "write" );
Extra_UtilGetoptReset(); 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) { switch(c) {
case 'c': case 'c':
if( Vec_StrSize(sCommandUsr) > 0 ) if( Vec_StrSize(sCommandUsr) > 0 )
...@@ -134,6 +135,15 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -134,6 +135,15 @@ int Abc_RealMain( int argc, char * argv[] )
fBatch = BATCH_QUIET; fBatch = BATCH_QUIET;
break; break;
case 'Q':
if( Vec_StrSize(sCommandUsr) > 0 )
{
Vec_StrAppend(sCommandUsr, " ; ");
}
Vec_StrAppend(sCommandUsr, globalUtilOptarg );
fBatch = BATCH_QUIET_THEN_INTERACTIVE;
break;
case 'C': case 'C':
if( Vec_StrSize(sCommandUsr) > 0 ) if( Vec_StrSize(sCommandUsr) > 0 )
{ {
...@@ -242,14 +252,13 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -242,14 +252,13 @@ 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!=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) ); Abc_Print( 1, "ABC command line: \"%s\".\n\n", Vec_StrArray(sCommandUsr) );
if ( fBatch!=INTERACTIVE ) if ( fBatch!=INTERACTIVE )
{ {
pAbc->fBatchMode = 1; pAbc->fBatchMode = 1;
if (argc - globalUtilOptind == 0) if (argc - globalUtilOptind == 0)
{ {
sInFile = NULL; sInFile = NULL;
...@@ -288,7 +297,7 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -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; fBatch = INTERACTIVE;
pAbc->fBatchMode = 0; pAbc->fBatchMode = 0;
} }
...@@ -375,4 +384,3 @@ static int TypeCheck( Abc_Frame_t * pAbc, const char * s ) ...@@ -375,4 +384,3 @@ static int TypeCheck( Abc_Frame_t * pAbc, const char * s )
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_END
...@@ -121,11 +121,12 @@ void Abc_UtilsPrintUsage( Abc_Frame_t * pAbc, char * ProgName ) ...@@ -121,11 +121,12 @@ void Abc_UtilsPrintUsage( Abc_Frame_t * pAbc, char * ProgName )
{ {
fprintf( pAbc->Err, "\n" ); fprintf( pAbc->Err, "\n" );
fprintf( pAbc->Err, 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); 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, " -q cmd\texecute commands `cmd' quietly\n");
fprintf( pAbc->Err, " -C cmd\texecute commands `cmd', then continue in interactive mode\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 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");
...@@ -291,4 +292,3 @@ char * DateReadFromDateString( char * datestr ) ...@@ -291,4 +292,3 @@ char * DateReadFromDateString( char * datestr )
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_END
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