summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2020-10-21 19:10:37 +0200
committerSébastien Helleu <flashcode@flashtux.org>2020-10-21 19:10:37 +0200
commit0ff08e54f5f0715c2e4c27a8c987d844be1a462e (patch)
tree9c3e2fbaadcadfd7e2a5be9bd7f05149ca100563
parent30e48336f46ff68598e9007445dbfa9f5dd00865 (diff)
downloadweechat-0ff08e54f5f0715c2e4c27a8c987d844be1a462e.zip
trigger: add variable "tg_argc" in data set by command trigger (closes #1576)
-rw-r--r--ChangeLog.adoc1
-rw-r--r--doc/de/weechat_user.de.adoc8
-rw-r--r--doc/en/weechat_user.en.adoc5
-rw-r--r--doc/fr/weechat_user.fr.adoc5
-rw-r--r--doc/it/weechat_user.it.adoc5
-rw-r--r--doc/ja/weechat_user.ja.adoc8
-rw-r--r--doc/pl/weechat_user.pl.adoc8
-rw-r--r--src/plugins/trigger/trigger-callback.c4
8 files changed, 31 insertions, 13 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index fa51080ba..e3ac86cd7 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -29,6 +29,7 @@ New features::
* irc: allow to send text on buffers with commands /allchan, /allpv and /allserv
* irc: evaluate command executed by commands /allchan, /allpv and /allserv (issue #1536)
* script: add option script.scripts.download_enabled (issue #1548)
+ * trigger: add variable "tg_argc" in data set by command trigger (issue #1576)
* trigger: add variable "tg_trigger_name" in data set by all triggers (issue #1567, issue #1568)
Bug fixes::
diff --git a/doc/de/weechat_user.de.adoc b/doc/de/weechat_user.de.adoc
index e18cef211..fbb2c1a13 100644
--- a/doc/de/weechat_user.de.adoc
+++ b/doc/de/weechat_user.de.adoc
@@ -4297,8 +4297,12 @@ Der Callback von "command" legt folgende Variablen in der Hashtable an:
|===
| Variable | Typ | Beschreibung
| buffer | pointer | Buffer.
-| tg_argvN | string | Argument #N.
-| tg_argv_eolN | string | von Argument #N bis zum Ende der Argumente.
+// TRANSLATION MISSING
+| tg_argc | string | The number of arguments (the command itself counts for one).
+// TRANSLATION MISSING
+| tg_argvN | string | Argument #N (`+tg_argv0+` is the command itself, the others are command arguments).
+// TRANSLATION MISSING
+| tg_argv_eolN | string | von Argument #N bis zum Ende der Argumente (`+tg_argv_eol0+` includes the command itself).
|===
[[trigger_data_command_run]]
diff --git a/doc/en/weechat_user.en.adoc b/doc/en/weechat_user.en.adoc
index 75dd78e22..e06a27a59 100644
--- a/doc/en/weechat_user.en.adoc
+++ b/doc/en/weechat_user.en.adoc
@@ -4205,8 +4205,9 @@ The "command" callback sets following variables in hashtable:
|===
| Variable | Type | Description
| buffer | pointer | Buffer.
-| tg_argvN | string | Argument #N.
-| tg_argv_eolN | string | From argument #N until end of arguments.
+| tg_argc | string | The number of arguments (the command itself counts for one).
+| tg_argvN | string | Argument #N (`+tg_argv0+` is the command itself, the others are command arguments).
+| tg_argv_eolN | string | From argument #N until end of arguments (`+tg_argv_eol0+` includes the command itself).
|===
[[trigger_data_command_run]]
diff --git a/doc/fr/weechat_user.fr.adoc b/doc/fr/weechat_user.fr.adoc
index 86c08b5fc..715c9478f 100644
--- a/doc/fr/weechat_user.fr.adoc
+++ b/doc/fr/weechat_user.fr.adoc
@@ -4348,8 +4348,9 @@ de hachage :
|===
| Variable | Type | Description
| buffer | pointeur | Tampon.
-| tg_argvN | chaîne | Paramètre n°N.
-| tg_argv_eolN | chaîne | Depuis le paramètre n°N jusqu'à la fin des paramètres.
+| tg_argc | chaîne | Nombre de paramètres (la commande elle-même compte pour un).
+| tg_argvN | chaîne | Paramètre n°N (`+tg_argv0+` est la commande elle-même, les autres sont les paramètres de la commande).
+| tg_argv_eolN | chaîne | Depuis le paramètre n°N jusqu'à la fin des paramètres (`+tg_argv_eol0+` inclut la commande elle-même).
|===
[[trigger_data_command_run]]
diff --git a/doc/it/weechat_user.it.adoc b/doc/it/weechat_user.it.adoc
index 0f82449e5..49993db80 100644
--- a/doc/it/weechat_user.it.adoc
+++ b/doc/it/weechat_user.it.adoc
@@ -4513,8 +4513,9 @@ The "command" callback sets following variables in hashtable:
|===
| Variable | Type | Description
| buffer | pointer | Buffer.
-| tg_argvN | string | Argument #N.
-| tg_argv_eolN | string | From argument #N until end of arguments.
+| tg_argc | string | The number of arguments (the command itself counts for one).
+| tg_argvN | string | Argument #N (`+tg_argv0+` is the command itself, the others are command arguments).
+| tg_argv_eolN | string | From argument #N until end of arguments (`+tg_argv_eol0+` includes the command itself).
|===
[[trigger_data_command_run]]
diff --git a/doc/ja/weechat_user.ja.adoc b/doc/ja/weechat_user.ja.adoc
index 4c36c8b84..8341c4f55 100644
--- a/doc/ja/weechat_user.ja.adoc
+++ b/doc/ja/weechat_user.ja.adoc
@@ -4248,8 +4248,12 @@ _weechat_print_ 修飾子では、メッセージタグを使う変数 (下の
|===
| 変数 | 型 | 説明
| buffer | pointer | バッファ
-| tg_argvN | string | N 番目の引数
-| tg_argv_eolN | string | N 番目の引数から最後の引数まで
+// TRANSLATION MISSING
+| tg_argc | string | The number of arguments (the command itself counts for one).
+// TRANSLATION MISSING
+| tg_argvN | string | N 番目の引数 (`+tg_argv0+` is the command itself, the others are command arguments).
+// TRANSLATION MISSING
+| tg_argv_eolN | string | N 番目の引数から最後の引数まで (`+tg_argv_eol0+` includes the command itself).
|===
[[trigger_data_command_run]]
diff --git a/doc/pl/weechat_user.pl.adoc b/doc/pl/weechat_user.pl.adoc
index b93bf2393..4fc867bac 100644
--- a/doc/pl/weechat_user.pl.adoc
+++ b/doc/pl/weechat_user.pl.adoc
@@ -4244,8 +4244,12 @@ Callback "command" ustawia następujące zmienne w tablicy hashy:
|===
| Zmienna | Typ | Opis
| buffer | wskaźnik | Bufor.
-| tg_argvN | ciąg | Argument #N.
-| tg_argv_eolN | ciąg | Od argumentu #N do końca argumentów.
+// TRANSLATION MISSING
+| tg_argc | ciąg | The number of arguments (the command itself counts for one).
+// TRANSLATION MISSING
+| tg_argvN | ciąg | Argument #N (`+tg_argv0+` is the command itself, the others are command arguments).
+// TRANSLATION MISSING
+| tg_argv_eolN | ciąg | Od argumentu #N do końca argumentów (`+tg_argv_eol0+` includes the command itself).
|===
[[trigger_data_command_run]]
diff --git a/src/plugins/trigger/trigger-callback.c b/src/plugins/trigger/trigger-callback.c
index c2625265d..195f16899 100644
--- a/src/plugins/trigger/trigger-callback.c
+++ b/src/plugins/trigger/trigger-callback.c
@@ -1042,7 +1042,7 @@ trigger_callback_command_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
- char str_name[32];
+ char str_name[32], str_temp[128];
int i;
TRIGGER_CALLBACK_CB_INIT(WEECHAT_RC_OK);
@@ -1053,6 +1053,8 @@ trigger_callback_command_cb (const void *pointer, void *data,
/* add data in hashtables used for conditions/replace/command */
trigger_callback_set_common_vars (trigger, extra_vars);
weechat_hashtable_set (pointers, "buffer", buffer);
+ snprintf (str_temp, sizeof (str_temp), "%d", argc);
+ weechat_hashtable_set (extra_vars, "tg_argc", str_temp);
for (i = 0; i < argc; i++)
{
snprintf (str_name, sizeof (str_name), "tg_argv%d", i);