X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FMainpage.dox;h=42187b72fa5b0e2b95ff879aa38a00cc4b2e08a6;hb=259da4c692259311c6ec99566b57f5ed1e68e93e;hp=b63300e90e2b0ff70c7fbb4aa35ea9685646b00c;hpb=f47679431aa3461936ee4a85c0c4216e44292b55;p=senf.git diff --git a/Console/Mainpage.dox b/Console/Mainpage.dox index b63300e..42187b7 100644 --- a/Console/Mainpage.dox +++ b/Console/Mainpage.dox @@ -109,7 +109,7 @@ From this information the command callback gets a list of arguments or tokens which then can be interpreted in an arbitrary way. \code - void test1(std::ostream & os, senf::console::ParseCommandInfo const & command) + void fun1(std::ostream & os, senf::console::ParseCommandInfo const & command) { // We take exactly one argument if (command.arguments().size() != 1) @@ -134,7 +134,7 @@ 'doc()': \code senf::console::root() - .add("test1", &test1) + .add("test1", &fun1) .doc("Usage:\n" " test1 arg\n" "\n" @@ -178,7 +178,7 @@ feature allows to register (almost) arbitrary callbacks. \code - std::string test2(std::string const & arg) + std::string fun(std::string const & arg) { return arg; } @@ -188,7 +188,7 @@ senf::console::DirectoryNode. \code senf::console::root() - .add("test2", &test2); + .add("test2", &fun2); \endcode The functionality is now identical to \c test1: \htmlonly @@ -257,7 +257,7 @@ raised. \code - void test3(std::ostream & os, unsigned n, std::string text) + void fun3(std::ostream & os, unsigned n, std::string text) { // It's perfectly valid to check additional constraints here and throw a // SyntaxErrorException. In this case, the next overload will be tried. However, you must @@ -269,18 +269,18 @@ using namespace senf::console::kw; senf::console::root() - .add("test3", &test3) + .add("test3", &fun3) .doc("Echo text to the console") .overloadDoc("Repeat 'text' for 'n' lines") .arg( name = "n", description = "Number of repetitions" ) .arg( name = "text", description = "Message to output" ); senf::console::root() - .add("test3", &test2) + .add("test3", &fun2) .overloadDoc("Echo the 'text' argument") - .arg( name = "text", description = "Message to output" ); + .arg( name = "text" ); \endcode - We can now call \c test2 with one or two arguments: + We can now call \c test3 with one or two arguments: \htmlonly
@@ -320,15 +320,36 @@
     using namespace senf::console::kw;
 
     senf::console::root()
-        .add("test4", &test2b)
-        .arg()
-        .arg( default_value = "ok" );
+        .add("test4", &fun3)
+        .arg( name = "n", description = "Number of repetitions", default_value = 1 )
+        .arg( name = "text", description = "Message to output" );
     \endcode
-    (Default values must not necessarily be declared in the callback function too.) Of course,
-    default values can be used together with overloading. 
 
-    There must be no argument without default value after an argument with a default value
-    declared. This fill fail at compile time. 
+    (Default values must not necessarily be declared in the callback function too.) Of course,
+    default values can be used together with overloading. Default (optional) value support is quite
+    flexible, it is not mandatory, for default values to be specified only for the trailing
+    arguments.
+    
+    \htmlonly
+    
+    server:/$ test4 echo
+    echo
+    server:/$ test4 4 ok
+    ok
+    ok
+    ok
+    ok
+    server:/$ help test4
+    Usage:
+        test4 [n:unsigned] text:string
+    
+    With:
+        n         Number of repetitions
+        text      Message to output
+            default value: ok
+    server:/$
+    
+ \endhtmlonly \subsection console_auto_summary Attribute summary @@ -348,16 +369,18 @@ \li \e default_value: Arguments default value + + See senf::console::ParsedArgumentAttributor 'List of all members' \section console_memberfn Registering member functions Member functions are supported like non-member functions. They must however be added through a - senf::console::ScopedDirectory<> instance to bind them to their instance. + senf::console::ScopedDirectory instance to bind them to their instance. \code class Test { public: - ScopedDirectory dir; + senf::console::ScopedDirectory dir; Test(std::string label) : dir(this), label_ (label) { dir.add("test4", &Test::test2); @@ -379,7 +402,7 @@ \endcode Binding via senf::console::ScopedDirectory ensures, that the commands are automatically removed - from the tree when an object is destroyed. + from the tree when the object is destroyed. */