Version parameter added

This commit is contained in:
F. Y. H. 2023-07-24 03:31:46 +02:00
parent 9322b2315c
commit a7af43bc32
Signed by: Alnotz
GPG key ID: B808CA1113935C00
3 changed files with 74 additions and 32 deletions

View file

@ -3,31 +3,18 @@
#include "essai.h" #include "essai.h"
#include "essai-command.h" #include "essai-command.h"
int essai_command(const void *pointer, int essai_args_command(struct t_gui_buffer *buffer,
void *data,
struct t_gui_buffer *buffer,
int argc, int argc,
char **argv, char **argv,
char **argv_eol){ char **argv_eol){
int weechat_rc; weechat_printf(buffer,
"Nombre darguments : %s%d%s",
if(weechat_buffer_match_list(buffer,
"core.weechat")){
weechat_printf(NULL,
"Nombre darguments : %s%d%s\n"
"Commande 0 : %s%s%s\n"
"Commande 0 (fin de ligne) : %s%s%s",
weechat_color("blue"), weechat_color("blue"),
argc, argc,
weechat_color("reset"),
weechat_color("green"),
argv[0],
weechat_color("reset"),
weechat_color("green"),
argv_eol[0],
weechat_color("reset")); 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 : %s%s%s\n"
"Commande %d (fin de ligne) : %s%s%s", "Commande %d (fin de ligne) : %s%s%s",
i, i,
@ -39,23 +26,78 @@ int essai_command(const void *pointer,
argv_eol[i], argv_eol[i],
weechat_color("reset")); 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; weechat_rc = WEECHAT_RC_OK;
} else { } else {
weechat_printf(NULL, weechat_printf(NULL,
"Il ny a que dans ce tampon que la commande %s/essai%s est possible.", "Il ny a que dans ce tampon que la commande %s/essai%s est possible.",
weechat_color("italic"), weechat_color("italic"),
weechat_color("-italic")); weechat_color("-italic"));
weechat_rc = WEECHAT_RC_ERROR; weechat_rc = WEECHAT_RC_ERROR;
} }
return weechat_rc; return weechat_rc;
} }
void essai_command_init(){ void essai_command_init(){
weechat_hook_command("1000|essai", weechat_hook_command("1000|essai",
"Une commande dessai", "Une commande dessai.",
"[version]", "[-arg | -version]",
"version : description du greffon", " -arg : essai sur les arguments,\n"
"version %-", "-version : versions.",
"-arg %- || -version %-",
&essai_command, &essai_command,
NULL, NULL,
NULL); NULL);

View file

@ -1,6 +1,6 @@
/* /*
gcc $(pkg-config --cflags weechat) \ 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) $(pkg-config --libs weechat)
*/ */
#include <stdlib.h> #include <stdlib.h>

View file

@ -6,7 +6,7 @@
#define ESSAI_PLUGIN_NAME "essai" #define ESSAI_PLUGIN_NAME "essai"
#define ESSAI_PLUGIN_DESCRIPTION "Plugin just to test the library :-/" #define ESSAI_PLUGIN_DESCRIPTION "Plugin just to test the library :-/"
#define ESSAI_PLUGIN_AUTHOR "Alnotz" #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_LICENCE "GPL-3.0-or-later"
#define ESSAI_PLUGIN_PRIORITY 999 #define ESSAI_PLUGIN_PRIORITY 999