Clark C. Evans avatar Clark C. Evans committed f874800

correcting syntax in plugin documentation,
giving example hello command some plugin arguments

Comments (0)

Files changed (2)


 For example, the ``autolimit`` extension truncates at ``limit`` number
 of rows.  The default is 10k, but this ``limit`` can be set::
-  $ htsql-ctl shell -E tweak.autolimit;limit=10 pgsql:htsql_regress
+  $ htsql-ctl shell -E tweak.autolimit:limit=10 pgsql:htsql_regress
-  ^ this is wrong; how do you set parameters again?
+If more than one parameter is possible, use "," to seperate them::
+  $ htsql-ctl shell -E tweak.hello:repeat=3,address=home pgsql:htsql_regress 
 Config Files


+from htsql.context import context
 from htsql.adapter import adapts, named
-from htsql.addon import Addon
+from htsql.addon import Addon, Parameter
 from import BindCommand
 from import CommandBinding
 from import NullarySig
 from htsql.cmd.command import Command
 from htsql.cmd.act import Act, RenderAction
+from htsql.validator import PIntVal, ChoiceVal
 class HelloCmd(Command):
     def __call__(self):
         status = "200 OK"
+        address =
+        repeat =
+        line = "Hello, " + address.capitalize() + "!\n"
         headers = [('Content-Type', "text/plain; charset=UTF-8")]
-        body = ["Hello, World!"]
+        body = [line * repeat]
         return (status, headers, body)
 class TweakHelloAddon(Addon):
+    name = 'tweak.hello'
+    hint = """example plugin and example /hello() world command"""
+    help = """
+      This is an example plugin and command.  It has two parameters
+      ``address`` which defaults to 'world' and ``repeat`` which
+      defaults to 1.  The plugin registers a command ``/hello()``
+      that prints "Hello, X!" several times.  It can be started 
+      using a command line::
-    name = 'tweak.hello'
+       htsql-ctl shell htsql_regress -E tweak.hello:address=mom,repeat=3
+    """
+    parameters = [
+            Parameter('repeat', PIntVal(), default=1),
+            Parameter('address', ChoiceVal(['mom','home','world']), 
+                                 default='world')
+    ]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.