Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap-plugins-python
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
libdap-plugins-python
Commits
85a6e51d
Commit
85a6e51d
authored
4 years ago
by
alexey.stratulat
Browse files
Options
Downloads
Patches
Plain Diff
[+] Added function for create commands and handler commands.
parent
9085029d
No related branches found
No related tags found
1 merge request
!4
Features 2954
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/dap_chain_plugins_command.h
+18
-0
18 additions, 0 deletions
include/dap_chain_plugins_command.h
src/dap_chain_plugins_command.c
+69
-0
69 additions, 0 deletions
src/dap_chain_plugins_command.c
with
87 additions
and
0 deletions
include/dap_chain_plugins_command.h
0 → 100644
+
18
−
0
View file @
85a6e51d
#include
"dap_chain_node_cli.h"
#include
"dap_chain_node_cli_cmd.h"
#include
"dap_chain_plugins_manifest.h"
#include
"dap_chain_plugins.h"
#ifdef __cplusplus
extern
"C"
{
#endif
#undef LOG_TAG
#define LOG_TAG "dap_chain_plugins_command"
void
dap_chain_plugins_command_create
(
void
);
int
dap_chain_plugins_command_handler
(
int
a_argc
,
char
**
a_argv
,
void
*
a_arg_func
,
char
**
a_str_reply
);
#ifdef __cplusplus
}
#endif
This diff is collapsed.
Click to expand it.
src/dap_chain_plugins_command.c
0 → 100644
+
69
−
0
View file @
85a6e51d
#include
"dap_chain_plugins_command.h"
static
bool
restart_plugins
=
false
;
void
dap_chain_plugins_command_create
(
void
){
if
(
!
restart_plugins
){
dap_chain_node_cli_cmd_item_create
(
"plugins"
,
dap_chain_plugins_command_handler
,
NULL
,
"Commands for working with plugins."
,
"plugins list
\t
- show list plugins
\n
"
"plugins show --name <name_plugin>
\t
-show information for plugin
\n
"
"plugins restart
\t
-Restart all plugins
\n
"
"plugins reload --name <name_plugin>
\t
-Restart plugin
\n\n
"
);
restart_plugins
=
true
;
}
}
int
dap_chain_plugins_command_handler
(
int
a_argc
,
char
**
a_argv
,
void
*
a_arg_func
,
char
**
a_str_reply
){
enum
{
CMD_NONE
,
CMD_LIST
,
CMD_SHOW_NAME
,
CMD_RESTART
,
CMD_RELOAD_NAME
};
int
arg_index
=
1
;
int
cmd_name
=
CMD_NONE
;
const
char
*
name_plugin
=
NULL
;
dap_chain_plugins_list_manifest_t
*
element
=
NULL
;
if
(
dap_chain_node_cli_find_option_val
(
a_argv
,
arg_index
,
a_argc
,
"list"
,
NULL
))
cmd_name
=
CMD_LIST
;
if
(
dap_chain_node_cli_find_option_val
(
a_argv
,
arg_index
,
a_argc
,
"show"
,
NULL
))
cmd_name
=
CMD_SHOW_NAME
;
if
(
dap_chain_node_cli_find_option_val
(
a_argv
,
arg_index
,
a_argc
,
"restart"
,
NULL
))
cmd_name
=
CMD_RESTART
;
if
(
dap_chain_node_cli_find_option_val
(
a_argv
,
arg_index
,
a_argc
,
"reload"
,
NULL
))
cmd_name
=
CMD_RELOAD_NAME
;
switch
(
cmd_name
)
{
case
CMD_LIST
:
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"|
\t
Name plugin
\t
|
\t
Version
\t
|
\t
Author(s)
\t
|"
);
LL_FOREACH
(
dap_chain_plugins_manifests_get_list
(),
element
){
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"|
\t
%s
\t
|
\t
%s
\t
|
\t
%s
\t
|"
,
element
->
name
,
element
->
version
,
element
->
author
);
}
break
;
case
CMD_SHOW_NAME
:
dap_chain_node_cli_find_option_val
(
a_argv
,
arg_index
,
a_argc
,
"--name"
,
&
name_plugin
);
LL_SEARCH
(
dap_chain_plugins_manifests_get_list
(),
element
,
name_plugin
,
dap_chain_plugins_manifest_name_cmp
);
if
(
element
!=
NULL
){
char
*
dep
=
dap_chain_plugins_manifests_get_list_dependencyes
(
element
);
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"Name: %s
\n
Version: %s
\n
Author: %s"
"Description: %s
\n
Dependencys: %s
\n\n
"
,
element
->
name
,
element
->
version
,
element
->
author
,
element
->
dependencys
,
dep
);
DAP_FREE
(
dep
);
}
else
{
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"Can't searching plugin with name %s"
,
name_plugin
);
}
break
;
case
CMD_RESTART
:
log_it
(
L_NOTICE
,
"Start procedure restart python plugins module"
);
dap_chain_plugins_deinit
();
dap_chain_plugins_init
();
log_it
(
L_NOTICE
,
"Done procedure restart python plugins module"
);
break
;
case
CMD_RELOAD_NAME
:
break
;
default:
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"Not validation parameters"
);
break
;
}
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment