1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Compare commits

...

1 Commits

Author SHA1 Message Date
abv
6d61efef1e 0029024: DRAW - use common approach for reporting error message on wrong command arguments
Method Draw_Interpretor::ErrorOnWrongArgs() is added, providing user message for DRAW command called with incorrect arguments.
2017-08-21 16:48:23 +03:00
2 changed files with 38 additions and 0 deletions

View File

@@ -331,6 +331,34 @@ Standard_Boolean Draw_Interpretor::Remove(Standard_CString const n)
return result == 0;
}
//=======================================================================
//function : GetHelp
//purpose :
//=======================================================================
Standard_CString Draw_Interpretor::GetHelp (Standard_CString theCommandName) const
{
return Tcl_GetVar2 (myInterp, "Draw_Helps", theCommandName, TCL_GLOBAL_ONLY);
}
//=======================================================================
//function : ErrorOnWrongArgs
//purpose :
//=======================================================================
Standard_Integer Draw_Interpretor::ErrorOnWrongArgs (Standard_CString theCommandName) const
{
std::cerr << "Error: wrong number of arguments" << std::endl;
Standard_CString aHelp = GetHelp (theCommandName);
if (aHelp)
{
std::cerr << "Use: " << theCommandName << " " << aHelp << std::endl;
}
return 1;
}
//=======================================================================
//function : Result
//purpose :

View File

@@ -164,6 +164,16 @@ public:
//! Removes <theCommandName>, returns true if success (the command existed).
Standard_EXPORT Standard_Boolean Remove (const Standard_CString theCommandName);
//! Returns text of the help recorded for command theCommandName
//! (previously added by method Add() or by command "help" in Tcl interpretor).
//! Returns Null if no help string is defined for theCommandName.
Standard_EXPORT Standard_CString GetHelp (Standard_CString theCommandName) const;
//! Prints (to std::cerr) standard error message for theCommandName called with
//! wrong number of arguments. The message includes help for this command.
//! Returns 1 indicating error status for Tcl command.
Standard_EXPORT Standard_Integer ErrorOnWrongArgs (Standard_CString theCommandName) const;
public:
Standard_EXPORT Standard_CString Result() const;