Last days new release of Dinemic framework and PyDinemic library was published. Se what’s new
Libdinemic:
DApp
commands – newDApp
API allows to launch dinemic app in new way. Instead creating methods for handle create, oneshot and remove actions, you can handle multiple actions, for example by specyfing the model:./myapplication person create
. Modes--oneshot
--create
and--remove
will be removed in next releases. Only mode that still will be used is--launch
, that puts application into infinite listener mode, to catch any incoming updates of database- Fixed object remove – version 20.01 properly handles removing objects from object lists in
StorageInterfaces
. New virtual method was added inStoreInterface
to handle object removal processed in classSyncInterface
. Processing update with actionREMOVE
was not notifyingStoreInterface
to remove registered object. - Help text is now highlighted. Due to large amount of text, that is generated from commands, some sections and options/commands are now highlighted. All colors could be customized by
Dinemic::text_...
variables, fromdapp.h
file
How to use commands?
Beside the get_option
, add_option
and has_option
methods from DApp
class, you could use now commands. By calling add_option
in DApp
(or derived class) constructor you can add new options, like “--object-id
“. To create new instances of objects, previous versions of Dinemic required to call as following:
./myapp --create --person-name Maciej --person-email me@dinemic.io
./myapp --oneshot --person-edit --person-id Person:1234... --person-name=Hugo
It was possible to implement edit, but it was not very intuitive. Now it is possible to change that behavior to following:
./myapp person create --name Maciej --email me@dinemic.io
./myapp person edit Person:1234... --name Hugo
Commands don’t require any options to be provided. If application don’t find any of previous: create, oneshot, remove or help, then starts looking for commands.
To add new command, just put following line in constructor of your application:
add_command(vector<string>{"person", "create"}, &Person::command_create, vector<string>{"name", "email"}, "Create new person");
Method handling such command should have following signature:
static void command_NAME(DApp *app, std::vector<string> commands);
As DApp pointer, dinemic will pass current application. The vector of commands, there will be passed all remaining tokens, like person id, in above example. Add_command has following parameters:
- List of tokens – defines which keywords should identify this command
- Pointer to handler method
- List of required parameters – could be empty vector. All names of parameters (as name and email in above example) are required to call method. If any element of this list has format of
[name]
, then it will be treated as required parameter (without leading dashes). Such parameter, in square brackets is not treated as option (with — or -). It just appears in command handler incommand
list - Command description
PyDinemic 20.01
Also new release of PyDinemic was published in PyPi. Besides the binary compatibility with C++ Dinemic, it was renamed to dinemic
module. Now, just call:
import dinemic
instead import pydinemic
. The legacy pydinemic
package was also updated and will no longer be maintained under that name. Instead, use import of dinemic
.
Recent Comments