]> OCCT Git - occt-copy.git/commitdiff
0029024: DRAW - use common approach for reporting error message on wrong command... CR29024
authorabv <abv@opencascade.com>
Mon, 21 Aug 2017 13:48:23 +0000 (16:48 +0300)
committerabv <abv@opencascade.com>
Mon, 21 Aug 2017 13:48:23 +0000 (16:48 +0300)
Method Draw_Interpretor::ErrorOnWrongArgs() is added, providing user message for DRAW command called with incorrect arguments.

src/Draw/Draw_Interpretor.cxx
src/Draw/Draw_Interpretor.hxx

index 025df3183f5579b5856fa59da8ea12814d630d1f..c7398fc4b9a496675ee218ad11ca3243d5aa84dd 100644 (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  : 
index 9e113bc6960cd1f1a51af5e0e41f17ee3f4e34ad..cf051a8366788cabb59cd2c64ed43325f4b53e91 100644 (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;