summaryrefslogtreecommitdiff
path: root/.config/nushell
diff options
context:
space:
mode:
authorWriterV2 <primary-v2@protonmail.com>2026-04-13 17:49:27 +0200
committerWriterV2 <primary-v2@protonmail.com>2026-04-13 20:03:03 +0200
commitb6e9a54f81de6254f85e7559ddf0256eb048fe5c (patch)
treeaa79a39de697e64d85e15d787b07c18c46724de9 /.config/nushell
parentfaf1dac649f4394fd71e648ec9ce87bcada8cf5e (diff)
Nushell: Add japanese-helper vocab WIP
Diffstat (limited to '.config/nushell')
-rw-r--r--.config/nushell/config.nu1
-rw-r--r--.config/nushell/japanese-helper.nu16
2 files changed, 17 insertions, 0 deletions
diff --git a/.config/nushell/config.nu b/.config/nushell/config.nu
index d94dcda..1fa9a1d 100644
--- a/.config/nushell/config.nu
+++ b/.config/nushell/config.nu
@@ -886,3 +886,4 @@ use phone.nu
use screen.nu
use wishlist.nu
use reading-order.nu
+use japanese-helper.nu
diff --git a/.config/nushell/japanese-helper.nu b/.config/nushell/japanese-helper.nu
new file mode 100644
index 0000000..6ba20b7
--- /dev/null
+++ b/.config/nushell/japanese-helper.nu
@@ -0,0 +1,16 @@
+export def "vocabulary get-id" [
+ search_term: string # search term that must exactly match either orth or hiragana reading
+] {
+ return (open $env.WADOKU_DUMP_PATH --raw
+ | rg "http://www.wadoku.de/xml/entry" --passthru --replace ""
+ | query xml $"//entry[form[/reading/hira='($search_term)' or orth='($search_term)']]/@id"
+ | get string_value)
+}
+
+export def "vocabulary show-by-id" [
+ id: string # wadoku XML entry id
+] {
+ open $env.WADOKU_DUMP_PATH --raw |
+ | rg "http://www.wadoku.de/xml/entry" --passthru --replace ""
+ | query xml $"//entry[@id=($id)]//node\(\)[self::sense or self::accent or self::orth or self::hira]" --output-string-value --output-names
+}