Updated the documentation
This commit is contained in:
parent
4cb66f52fe
commit
b4cee0e2e5
31 changed files with 267 additions and 296 deletions
40
_site/data/scriptmods/async.yaml
Normal file
40
_site/data/scriptmods/async.yaml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
module: async
|
||||
docs: |
|
||||
Provides commands for executing blocks asynchronously.
|
||||
|
||||
Asynchronous blocks are executed in the same thread as regular commands, so it's recommended
|
||||
to avoid long running operations in these blocks. Exception to these are commands which require fetching
|
||||
data from the database.
|
||||
symbols:
|
||||
- name: do
|
||||
syntax: async:do BLOCK
|
||||
docs: |
|
||||
Schedules a block to be executed at the conclusion of all other running commands.
|
||||
Blocks are place in a queue in the order the call to `async:do` is made, with a maximum
|
||||
queue size of 100 blocks. If the queue is full, the command will return an error.
|
||||
example: |
|
||||
async:do {
|
||||
echo "World"
|
||||
}
|
||||
echo "Hello"
|
||||
- name: in
|
||||
syntax: async:in SECONDS BLOCK
|
||||
docs: |
|
||||
Schedules a block to be executed in SECONDS seconds. Once the timout has ellapsed, the block will
|
||||
be placed on the queue and will be executed once all other pending blocks have been consumed.
|
||||
example: |
|
||||
async:in 5 {
|
||||
echo "5 seconds have ellapsed"
|
||||
}
|
||||
- name: query
|
||||
syntax: async:query EXPRESSION [QUERY_ARGS] BLOCK [OPTIONS]
|
||||
docs: |
|
||||
Executes the query in the background and schedules BLOCK once the resultset is available. The available
|
||||
options match that of rs:query.
|
||||
|
||||
Note: the RC files are invoked before the table picker is shown, so any async:query calls invoked during
|
||||
startup should have the `-table` option set.
|
||||
example: |
|
||||
async:query 'pk = $arg' [arg:"abc123"] { |rs|
|
||||
echo $rs.First.pk
|
||||
}
|
||||
22
_site/data/scriptmods/av.yaml
Normal file
22
_site/data/scriptmods/av.yaml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
module: av
|
||||
docs: |
|
||||
Provides commands for translating between UCL and DynamoDB types.
|
||||
symbols:
|
||||
- name: 'true'
|
||||
syntax: av:true
|
||||
docs: |
|
||||
Returns a true BOOL attribute value.
|
||||
- name: 'false'
|
||||
syntax: av:false
|
||||
docs: |
|
||||
Returns a false BOOL attribute value.
|
||||
- name: 'null'
|
||||
syntax: av:null
|
||||
docs: |
|
||||
Returns a NULL attribute value.
|
||||
- name: string-set
|
||||
syntax: av:string-set LIST
|
||||
docs: |
|
||||
Converts a list into a string set (SS) attribute value.
|
||||
example: |
|
||||
av:string-set [apple banana cherry]
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
module: ext
|
||||
docs: |
|
||||
Provides access to the extension points scripts can used to extend the functionality of Dynamo-Browse.
|
||||
|
||||
This module is only available for scripts loaded using the [load-script]() command.
|
||||
symbols:
|
||||
- name: command
|
||||
syntax: ext.command(name, fn)
|
||||
docs: |
|
||||
Defines a new command, which can be invoked by entering _name_ within the main view mode.
|
||||
The parameter _fn_ must be a function, which will be executed when the _name_ command is entered
|
||||
while in view mode.
|
||||
|
||||
The command can accept arguments, which will be passed in to the parameters of _fn_. The number
|
||||
of command arguments must match the number of parameters, except for any function arguments with
|
||||
a default value.
|
||||
example: |
|
||||
ext.command("add", func(x, y) {
|
||||
sum := x + y
|
||||
ui.print("x + y = ", sum)
|
||||
})
|
||||
- name: related_items
|
||||
syntax: ext.related_items(table, fn)
|
||||
docs: |
|
||||
Defines a "related item" for a table. These act as quick jumps between tables.
|
||||
When the user presses Shift+O, all the related item functions that match the given
|
||||
table will be evaluated. Each one is to return zero or more related queries, which are presented
|
||||
to the user as a list. When the user selects one, the query will be evaluated and the result set will
|
||||
be shown.
|
||||
|
||||
The _table_ parameter is the name of the table of the related items managed by this function.
|
||||
If the last character of the table is `*`, then _table_ will be treated as a name prefix.
|
||||
|
||||
The _fn_ will produce a list of queries that are related to a given item. The function takes the currently
|
||||
selected item as the argument, and is expected to produce a list of maps, with each map having the following
|
||||
fields:
|
||||
|
||||
- `label`: The label to use for the picker option
|
||||
- `query`: The query expression that will run when the option is chosen
|
||||
- `table`: The table to run the query over. If not set, the current table will be used
|
||||
- `args`: A map of query placeholder values
|
||||
- `on_select`: An optional function that will run in place of a predefined query. If set, the `query` field will
|
||||
be ignored.
|
||||
example: |
|
||||
ext.related_items("user-account", func(item) {
|
||||
return [
|
||||
{
|
||||
"label": "Customer",
|
||||
"table": "billing",
|
||||
"query": "email=$email",
|
||||
"args": {"email": item.attr("email")},
|
||||
},
|
||||
]
|
||||
})
|
||||
- name: key_binding
|
||||
syntax: ext.key_binding(name, options, fn)
|
||||
docs: |
|
||||
Defines a new key binding, which can be invoked while viewing the table.
|
||||
|
||||
The _name_ parameter defines the binding name. The binding names will be prefixed with
|
||||
`ext.<script_basename>`. This name can be used with the [rebind]() command.
|
||||
|
||||
The _option_ parameter defines a map of options. The only valid option is
|
||||
`default`, which is the default key to use for this binding. If unset, the binding will
|
||||
have no key binding and can only be bound using the [rebind]() command.
|
||||
|
||||
The _fn_ parameter is the function that will be invoked when the key is pressed.
|
||||
It must accept no parameters.
|
||||
example: |
|
||||
// Script name: sayhello.tm
|
||||
//
|
||||
// This binding can be rebound with the command "rebind ext.sayhello.hello <key>"
|
||||
ext.key_binding("hello", {"default": "H"}, func() {
|
||||
ui.print("Hello")
|
||||
})
|
||||
9
_site/data/scriptmods/opt.yaml
Normal file
9
_site/data/scriptmods/opt.yaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
module: opt
|
||||
docs: |
|
||||
Provides commands for modifying options.
|
||||
symbols:
|
||||
- name: 'set'
|
||||
syntax: opt:set NAME [VALUE]
|
||||
docs: |
|
||||
Returns the current value of the setting option NAME. If VALUE is present, modifies the setting option first before
|
||||
returning the value.
|
||||
14
_site/data/scriptmods/pb.yaml
Normal file
14
_site/data/scriptmods/pb.yaml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
module: pb
|
||||
docs: |
|
||||
Provides access to the pasteboard.
|
||||
symbols:
|
||||
- name: 'paste'
|
||||
syntax: pb:paste
|
||||
docs: |
|
||||
Returns the current text value of the paste board. If the paste board contains no text value,
|
||||
or is unavailable, returns the empty string.
|
||||
- name: 'copy'
|
||||
syntax: pb:copy VALUE
|
||||
docs: |
|
||||
Sets the current text value of the paste board to VALUE. If the paste board is unavailable, this
|
||||
command nops.
|
||||
|
|
@ -3,18 +3,25 @@ type: type
|
|||
docs: |
|
||||
Holds a collection of items returned from a query, or presented to a user.
|
||||
|
||||
A specific item of a result-set can be retrived using the subscript option. For example, `result[21]` will
|
||||
return the 21st item of the result-set from the first item. A negative index can be used to retrieve an
|
||||
item from the last item.
|
||||
A specific item of a result-set can be retrived using the subscript option. For example, `$result.(21)` will
|
||||
return the 21st item of the result-set from the first item.
|
||||
|
||||
There is no guarantee to the ordering of items within the result-set, although items are usually
|
||||
ordered based on the partition and sort key.
|
||||
symbols:
|
||||
- name: length
|
||||
syntax: resultset.length
|
||||
- name: Items
|
||||
syntax: '$resultset.Items'
|
||||
docs: |
|
||||
Returns the number of items within the result set.
|
||||
- name: table
|
||||
syntax: resultset.table
|
||||
Returns the items within the result set.
|
||||
- name: HasNextPage
|
||||
syntax: '$resultset.HasNextPage'
|
||||
docs: |
|
||||
Returns true if this result-set has another page. The next page can be retrieved by calling `rs:next-page $resultset`.
|
||||
- name: First
|
||||
syntax: '$resultset.First'
|
||||
docs: |
|
||||
Returns the first item of the result-set, or nil if the result set is empty. Shorthand for `$result.Items.(0)`.
|
||||
- name: Table
|
||||
syntax: '$resultset.Table'
|
||||
docs: |
|
||||
Returns information about the table this result set belongs to.
|
||||
37
_site/data/scriptmods/rs.yaml
Normal file
37
_site/data/scriptmods/rs.yaml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
module: rs
|
||||
docs: |
|
||||
Provides operations over result-sets, or commands which return result-sets.
|
||||
symbols:
|
||||
- name: new
|
||||
syntax: rs:new [-table TABLE]
|
||||
docs: |
|
||||
Creates a new, empty result-set. If -table is specific, will configure the result-set table to
|
||||
that of TABLE. Otherwise, the result-set will inherit the current table.
|
||||
- name: query
|
||||
syntax: rs:query EXPRESSION [ARGUMENTS] [-table TABLE]
|
||||
docs: |
|
||||
Invokes a query expression and returns the result as a result-set. The query can be invoked with
|
||||
ARGUMENTS, which must be a dictionary with key/value pairs that are made available to the query
|
||||
as either attribute placeholders (`:attr`), or value placeholders (`$value`).
|
||||
|
||||
If -table is specific, will run the query over TABLE. Otherwise, the query will be invoked
|
||||
over the current table.
|
||||
|
||||
Note that this command blocks the command thread until either the results are available, or if
|
||||
an error occurs. To avoid this, use 'async:query', which will run the query in the background.
|
||||
example: |
|
||||
results = rs:query 'pk = $myID' [myID:"abc132"] -table users
|
||||
- name: scan
|
||||
syntax: rs:scan [-table TABLE]
|
||||
docs: |
|
||||
Runs a table scan, returning the first page of results as a result-set. If -table is specific, will
|
||||
run the scan over TABLE. Otherwise, the scan will be over the current table.
|
||||
- name: next-page
|
||||
syntax: rs:next-page RESULTSET
|
||||
docs: |
|
||||
Runs the next page of results from the passed in result-set. This will depend on how RESULTSET was
|
||||
created. For example, if RESULTSET was from a query, this will return the next page of results from that
|
||||
query. Likewise, for scans.
|
||||
|
||||
If the next page is available, the results will be returned as a new result-set, leaving the original result-set
|
||||
unmodified. If no next page is available, then nil will be returned.
|
||||
Loading…
Add table
Add a link
Reference in a new issue