Version parameter added
This commit is contained in:
parent
9322b2315c
commit
a7af43bc32
3 changed files with 74 additions and 32 deletions
|
@ -3,31 +3,18 @@
|
|||
#include "essai.h"
|
||||
#include "essai-command.h"
|
||||
|
||||
int essai_command(const void *pointer,
|
||||
void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
int essai_args_command(struct t_gui_buffer *buffer,
|
||||
int argc,
|
||||
char **argv,
|
||||
char **argv_eol){
|
||||
int weechat_rc;
|
||||
|
||||
if(weechat_buffer_match_list(buffer,
|
||||
"core.weechat")){
|
||||
weechat_printf(NULL,
|
||||
"Nombre d’arguments : %s%d%s\n"
|
||||
"Commande 0 : %s%s%s\n"
|
||||
"Commande 0 (fin de ligne) : %s%s%s",
|
||||
weechat_printf(buffer,
|
||||
"Nombre d’arguments : %s%d%s",
|
||||
weechat_color("blue"),
|
||||
argc,
|
||||
weechat_color("reset"),
|
||||
weechat_color("green"),
|
||||
argv[0],
|
||||
weechat_color("reset"),
|
||||
weechat_color("green"),
|
||||
argv_eol[0],
|
||||
weechat_color("reset"));
|
||||
for(int i=1; i<argc; i++){
|
||||
weechat_printf(NULL,
|
||||
|
||||
for(int i=0; i<argc; i++){
|
||||
weechat_printf(buffer,
|
||||
"Commande %d : %s%s%s\n"
|
||||
"Commande %d (fin de ligne) : %s%s%s",
|
||||
i,
|
||||
|
@ -39,23 +26,78 @@ int essai_command(const void *pointer,
|
|||
argv_eol[i],
|
||||
weechat_color("reset"));
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
int essai_version_command(struct t_gui_buffer *buffer,
|
||||
int argc,
|
||||
char **argv,
|
||||
char **argv_eol){
|
||||
const char *weechat_version = weechat_info_get("version", NULL);
|
||||
weechat_printf(buffer,
|
||||
"Version de WeeChat : %s%s%s\n"
|
||||
"Version du greffon : %s" ESSAI_PLUGIN_VERSION "%s",
|
||||
weechat_color("green"),
|
||||
weechat_version,
|
||||
weechat_color("reset"),
|
||||
weechat_color("green"),
|
||||
weechat_color("reset"));
|
||||
|
||||
free((void*) weechat_version);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
int essai_command(const void *pointer,
|
||||
void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
int argc,
|
||||
char **argv,
|
||||
char **argv_eol){
|
||||
int weechat_rc = 0;
|
||||
|
||||
if(weechat_buffer_match_list(buffer,
|
||||
"core.weechat")){
|
||||
int i = 1;
|
||||
while(i<argc){
|
||||
if(!weechat_strcmp(argv[i], "-arg")){
|
||||
weechat_rc = essai_args_command(NULL,
|
||||
argc,
|
||||
argv,
|
||||
argv_eol);
|
||||
|
||||
break;
|
||||
} else if(!weechat_strcmp(argv[i], "-version") ||
|
||||
!weechat_strcmp(argv[i], "-v")){
|
||||
essai_version_command(buffer,
|
||||
argc,
|
||||
argv,
|
||||
argv_eol);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
weechat_rc = WEECHAT_RC_OK;
|
||||
} else {
|
||||
weechat_printf(NULL,
|
||||
"Il n’y a que dans ce tampon que la commande %s/essai%s est possible.",
|
||||
weechat_color("italic"),
|
||||
weechat_color("-italic"));
|
||||
|
||||
weechat_rc = WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
return weechat_rc;
|
||||
}
|
||||
|
||||
void essai_command_init(){
|
||||
weechat_hook_command("1000|essai",
|
||||
"Une commande d’essai",
|
||||
"[version]",
|
||||
"version : description du greffon",
|
||||
"version %-",
|
||||
"Une commande d’essai.",
|
||||
"[-arg | -version]",
|
||||
" -arg : essai sur les arguments,\n"
|
||||
"-version : versions.",
|
||||
"-arg %- || -version %-",
|
||||
&essai_command,
|
||||
NULL,
|
||||
NULL);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
gcc $(pkg-config --cflags weechat) \
|
||||
-shared -fPIC -Wall -Wextra essai.c essai-command.c -o ./essai.so \
|
||||
-shared -fPIC -Wall -Wextra essai.c essai-command.c -o essai.so \
|
||||
$(pkg-config --libs weechat)
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#define ESSAI_PLUGIN_NAME "essai"
|
||||
#define ESSAI_PLUGIN_DESCRIPTION "Plugin just to test the library :-/"
|
||||
#define ESSAI_PLUGIN_AUTHOR "Alnotz"
|
||||
#define ESSAI_PLUGIN_VERSION "0.1.0"
|
||||
#define ESSAI_PLUGIN_VERSION "0.2.0"
|
||||
#define ESSAI_PLUGIN_LICENCE "GPL-3.0-or-later"
|
||||
#define ESSAI_PLUGIN_PRIORITY 999
|
||||
|
||||
|
|
Loading…
Reference in a new issue