summaryrefslogtreecommitdiffstats
path: root/src/base/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/cmd')
-rw-r--r--src/base/cmd/cmd.c109
-rw-r--r--src/base/cmd/cmdInt.h2
-rw-r--r--src/base/cmd/cmdUtils.c37
3 files changed, 103 insertions, 45 deletions
diff --git a/src/base/cmd/cmd.c b/src/base/cmd/cmd.c
index e69bbc0e..9f087585 100644
--- a/src/base/cmd/cmd.c
+++ b/src/base/cmd/cmd.c
@@ -498,12 +498,13 @@ int CmdCommandUnalias( Abc_Frame_t * pAbc, int argc, char **argv )
******************************************************************************/
int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv )
{
- int fPrintAll;
+ int fPrintAll, fDetails;
int c;
fPrintAll = 0;
+ fDetails = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "ah" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "adh" ) ) != EOF )
{
switch ( c )
{
@@ -512,6 +513,9 @@ int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv )
fPrintAll ^= 1;
break;
break;
+ case 'd':
+ fDetails ^= 1;
+ break;
case 'h':
goto usage;
break;
@@ -523,13 +527,14 @@ int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv )
if ( argc != globalUtilOptind )
goto usage;
- CmdCommandPrint( pAbc, fPrintAll );
+ CmdCommandPrint( pAbc, fPrintAll, fDetails );
return 0;
usage:
- fprintf( pAbc->Err, "usage: help [-a] [-h]\n" );
+ fprintf( pAbc->Err, "usage: help [-a] [-d] [-h]\n" );
fprintf( pAbc->Err, " prints the list of available commands by group\n" );
fprintf( pAbc->Err, " -a toggle printing hidden commands [default = %s]\n", fPrintAll? "yes": "no" );
+ fprintf( pAbc->Err, " -d print usage details to all commands [default = %s]\n", fDetails? "yes": "no" );
fprintf( pAbc->Err, " -h print the command usage\n" );
return 1;
}
@@ -885,6 +890,9 @@ int CmdCommandUnsetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
******************************************************************************/
int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv )
{
+ if ( argc == 2 && !strcmp(argv[1], "-h") )
+ goto usage;
+
if ( pAbc->pNtkCur == NULL )
{
fprintf( pAbc->Out, "Empty network.\n" );
@@ -896,6 +904,7 @@ int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv )
if ( argc == 1 )
return CmdCommandRecall( pAbc, argc, argv );
+usage:
fprintf( pAbc->Err, "usage: undo\n" );
fprintf( pAbc->Err, " sets the current network to be the previously saved network\n" );
return 1;
@@ -921,13 +930,6 @@ int CmdCommandRecall( Abc_Frame_t * pAbc, int argc, char **argv )
char * pValue;
int iStepStart, iStepStop;
- if ( pAbc->pNtkCur == NULL )
- {
- fprintf( pAbc->Out, "Empty network.\n" );
- return 0;
- }
-
-
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
@@ -940,6 +942,12 @@ int CmdCommandRecall( Abc_Frame_t * pAbc, int argc, char **argv )
}
}
+ if ( pAbc->pNtkCur == NULL )
+ {
+ fprintf( pAbc->Out, "Empty network.\n" );
+ return 0;
+ }
+
// get the number of networks to save
pValue = Cmd_FlagReadByName( pAbc, "savesteps" );
// if the value of steps to save is not set, assume 1-level undo
@@ -1034,12 +1042,6 @@ int CmdCommandEmpty( Abc_Frame_t * pAbc, int argc, char **argv )
{
int c;
- if ( pAbc->pNtkCur == NULL )
- {
- fprintf( pAbc->Out, "Empty network.\n" );
- return 0;
- }
-
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
@@ -1052,6 +1054,12 @@ int CmdCommandEmpty( Abc_Frame_t * pAbc, int argc, char **argv )
}
}
+ if ( pAbc->pNtkCur == NULL )
+ {
+ fprintf( pAbc->Out, "Empty network.\n" );
+ return 0;
+ }
+
Abc_FrameDeleteAllNetworks( pAbc );
Abc_FrameRestart( pAbc );
return 0;
@@ -1635,6 +1643,13 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv )
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
+ if ( argc == 1 )
+ goto usage;
+ if ( strcmp( argv[1], "-h" ) == 0 )
+ goto usage;
+ if ( strcmp( argv[1], "-?" ) == 0 )
+ goto usage;
+
if ( pNtk == NULL )
{
fprintf( pErr, "Empty network.\n" );
@@ -1647,13 +1662,6 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv )
goto usage;
}
- if ( argc == 1 )
- goto usage;
- if ( strcmp( argv[1], "-h" ) == 0 )
- goto usage;
- if ( strcmp( argv[1], "-?" ) == 0 )
- goto usage;
-
// get the names from the resource file
if ( Cmd_FlagReadByName(pAbc, "siswin") )
pNameWin = Cmd_FlagReadByName(pAbc, "siswin");
@@ -1739,7 +1747,6 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv )
return 0;
usage:
- fprintf( pErr, "\n" );
fprintf( pErr, "Usage: sis [-h] <com>\n");
fprintf( pErr, " invokes SIS command for the current ABC network\n" );
fprintf( pErr, " (the executable of SIS should be in the same directory)\n" );
@@ -1778,6 +1785,13 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv )
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
+ if ( argc == 1 )
+ goto usage;
+ if ( strcmp( argv[1], "-h" ) == 0 )
+ goto usage;
+ if ( strcmp( argv[1], "-?" ) == 0 )
+ goto usage;
+
if ( pNtk == NULL )
{
fprintf( pErr, "Empty network.\n" );
@@ -1790,13 +1804,6 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv )
goto usage;
}
- if ( argc == 1 )
- goto usage;
- if ( strcmp( argv[1], "-h" ) == 0 )
- goto usage;
- if ( strcmp( argv[1], "-?" ) == 0 )
- goto usage;
-
// get the names from the resource file
if ( Cmd_FlagReadByName(pAbc, "mvsiswin") )
pNameWin = Cmd_FlagReadByName(pAbc, "mvsiswin");
@@ -1882,7 +1889,6 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv )
return 0;
usage:
- fprintf( pErr, "\n" );
fprintf( pErr, "Usage: mvsis [-h] <com>\n");
fprintf( pErr, " invokes MVSIS command for the current ABC network\n" );
fprintf( pErr, " (the executable of MVSIS should be in the same directory)\n" );
@@ -1992,6 +1998,14 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
+ if ( argc > 1 )
+ {
+ if ( strcmp( argv[1], "-h" ) == 0 )
+ goto usage;
+ if ( strcmp( argv[1], "-?" ) == 0 )
+ goto usage;
+ }
+
if ( pNtk == NULL )
{
fprintf( pErr, "Empty network.\n" );
@@ -2004,14 +2018,6 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
goto usage;
}
- if ( argc > 1 )
- {
- if ( strcmp( argv[1], "-h" ) == 0 )
- goto usage;
- if ( strcmp( argv[1], "-?" ) == 0 )
- goto usage;
- }
-
// get the names from the resource file
if ( Cmd_FlagReadByName(pAbc, "capowin") )
pProgNameCapoWin = Cmd_FlagReadByName(pAbc, "capowin");
@@ -2125,7 +2131,6 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
return 0;
usage:
- fprintf( pErr, "\n" );
fprintf( pErr, "Usage: capo [-h] <com>\n");
fprintf( pErr, " peforms placement of the current network using Capo\n" );
fprintf( pErr, " a Capo binary should be present in the same directory\n" );
@@ -2244,8 +2249,28 @@ usage:
******************************************************************************/
int CmdCommandVersion( Abc_Frame_t * pAbc, int argc, char **argv )
{
+ int c;
+
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+
printf("%s\n", Abc_UtilsGetVersion(pAbc));
return 0;
+
+usage:
+ fprintf( pAbc->Err, "usage: version [-h]\n" );
+ fprintf( pAbc->Err, " print the version string\n" );
+ fprintf( pAbc->Err, " -h : print the command usage\n");
+ return 1;
}
diff --git a/src/base/cmd/cmdInt.h b/src/base/cmd/cmdInt.h
index 2827e47b..dc6a46f6 100644
--- a/src/base/cmd/cmdInt.h
+++ b/src/base/cmd/cmdInt.h
@@ -77,7 +77,7 @@ extern FILE * CmdFileOpen( Abc_Frame_t * pAbc, char * sFileName, char * sMod
extern void CmdFreeArgv( int argc, char ** argv );
extern char ** CmdAddToArgv( int argc, char ** argv );
extern void CmdCommandFree( Abc_Command * pCommand );
-extern void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll );
+extern void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll, int fDetails );
extern void CmdPrintTable( st__table * tTable, int fAliases );
////////////////////////////////////////////////////////////////////////
diff --git a/src/base/cmd/cmdUtils.c b/src/base/cmd/cmdUtils.c
index 7f2e9b08..d86ecf7e 100644
--- a/src/base/cmd/cmdUtils.c
+++ b/src/base/cmd/cmdUtils.c
@@ -543,16 +543,17 @@ void CmdCommandFree( Abc_Command * pCommand )
SeeAlso []
***********************************************************************/
-void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll )
+void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll, int fDetails )
{
const char *key;
char *value;
st__generator * gen;
Abc_Command ** ppCommands;
Abc_Command * pCommands;
- int nCommands, i;
+ int nCommands, iGroupStart, i, j;
char * sGroupCur;
int LenghtMax, nColumns, iCom = 0;
+ FILE *backupErr = pAbc->Err;
// put all commands into one array
nCommands = st__count( pAbc->tCommands );
@@ -584,6 +585,8 @@ void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll )
// print the command by group
sGroupCur = NULL;
+ iGroupStart = 0;
+ pAbc->Err = pAbc->Out;
for ( i = 0; i < nCommands; i++ )
if ( sGroupCur && strcmp( sGroupCur, ppCommands[i]->sGroup ) == 0 )
{ // this command belongs to the same group as the previous one
@@ -595,6 +598,22 @@ void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll )
else
{ // this command starts the new group of commands
// start the new group
+ if ( fDetails && i != iGroupStart )
+ { // print help messages for all commands in the previous groups
+ fprintf( pAbc->Out, "\n" );
+ for ( j = iGroupStart; j < i; j++ )
+ {
+ fprintf( pAbc->Out, "\n" );
+ // fprintf( pAbc->Out, "--- %s ---\n", ppCommands[j]->sName );
+ char *tmp_cmd = ABC_ALLOC(char, strlen(ppCommands[j]->sName)+4);
+ (void) sprintf(tmp_cmd, "%s -h", ppCommands[j]->sName);
+ (void) Cmd_CommandExecute( pAbc, tmp_cmd );
+ ABC_FREE(tmp_cmd);
+ }
+ fprintf( pAbc->Out, "\n" );
+ fprintf( pAbc->Out, " ----------------------------------------------------------------------" );
+ iGroupStart = i;
+ }
fprintf( pAbc->Out, "\n" );
fprintf( pAbc->Out, "\n" );
fprintf( pAbc->Out, "%s commands:\n", ppCommands[i]->sGroup );
@@ -605,6 +624,20 @@ void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll )
// reset the command counter
iCom = 1;
}
+ if ( fDetails && i != iGroupStart )
+ { // print help messages for all commands in the previous groups
+ fprintf( pAbc->Out, "\n" );
+ for ( j = iGroupStart; j < i; j++ )
+ {
+ fprintf( pAbc->Out, "\n" );
+ // fprintf( pAbc->Out, "--- %s ---\n", ppCommands[j]->sName );
+ char *tmp_cmd = ABC_ALLOC(char, strlen(ppCommands[j]->sName)+4);
+ (void) sprintf(tmp_cmd, "%s -h", ppCommands[j]->sName);
+ (void) Cmd_CommandExecute( pAbc, tmp_cmd );
+ ABC_FREE(tmp_cmd);
+ }
+ }
+ pAbc->Err = backupErr;
fprintf( pAbc->Out, "\n" );
ABC_FREE( ppCommands );
}