summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackson Moore <jacksonmoore@tuta.io>2026-09-05 15:01:53 +0200
committerJackson Moore <jacksonmoore@tuta.io>2026-09-05 15:01:53 +0200
commit408c23872de49f055d886a2eb2a32214df399d53 (patch)
tree611c5648401c0a12cb82d38ba5ce47c9604903ff
parent1e8322ae5c36d42820b5109544ef0ef5ad3da443 (diff)
Compose entry use case
-rw-r--r--tests/invocation_intent_test.lua20
-rw-r--r--tests/package_shell_test.lua8
-rw-r--r--yazi-enter.yazi/main.lua15
3 files changed, 37 insertions, 6 deletions
diff --git a/tests/invocation_intent_test.lua b/tests/invocation_intent_test.lua
index 5eb3e3a..a00711d 100644
--- a/tests/invocation_intent_test.lua
+++ b/tests/invocation_intent_test.lua
@@ -4,11 +4,25 @@ local file = assert(io.open(entry_path, "rb"))
local source = assert(file:read("*a"))
file:close()
+local capture = [[
+capture_parser(parse_invocation_intent)
+]]
+local instrumented_source, replacement_count = source:gsub(
+ "\nreturn {\n\tentry = function",
+ "\n" .. capture .. "\nreturn {\n\tentry = function",
+ 1
+)
+assert(replacement_count == 1, "parser capture point must occur once")
+
local prompt_calls = 0
+local parser
local environment = {
error = error,
pairs = pairs,
type = type,
+ capture_parser = function(value)
+ parser = value
+ end,
ya = {
sync = function(callback)
return callback
@@ -20,11 +34,11 @@ local environment = {
},
}
-local chunk = assert(load(source, "@" .. entry_path, "t", environment))
-local plugin = chunk()
+assert(load(instrumented_source, "@" .. entry_path, "t", environment))()
+assert(type(parser) == "function", "invocation parser was not captured")
local function parse(args)
- return plugin:entry({ args = args })
+ return parser(args)
end
local function assert_equal(actual, expected, label)
diff --git a/tests/package_shell_test.lua b/tests/package_shell_test.lua
index 0f783ef..3982d42 100644
--- a/tests/package_shell_test.lua
+++ b/tests/package_shell_test.lua
@@ -31,6 +31,7 @@ local sync_callbacks = {}
local environment = {
cx = { active = { finder = nil, current = {} } },
error = error,
+ getmetatable = getmetatable,
pairs = pairs,
type = type,
ya = {
@@ -40,6 +41,9 @@ local environment = {
assert(type(callback) == "function", "ya.sync requires a function")
return callback
end,
+ input = function()
+ return { recv = function() return nil, 2 end }
+ end,
},
}
@@ -50,8 +54,8 @@ assert(sync_calls == 1, "expected one top-level synchronous transaction")
assert(type(plugin) == "table", "plugin must export a table")
assert(type(plugin.entry) == "function", "plugin must export an entry method")
-local intent = plugin:entry({ args = { "directory" } })
-assert(intent.mode == "directory", "entry shell must load with the bundled runtime")
+local result = plugin:entry({ args = { "directory" } })
+assert(result == 0, "entry shell must load with the bundled runtime")
assert(sync_callbacks[1](nil, "directory", "query") == 0, "commit must guard absent finder state")
print("package shell checks passed")
diff --git a/yazi-enter.yazi/main.lua b/yazi-enter.yazi/main.lua
index eb05b18..b31a7b0 100644
--- a/yazi-enter.yazi/main.lua
+++ b/yazi-enter.yazi/main.lua
@@ -336,8 +336,21 @@ local function run_selection_session(intent, boundaries)
end
end
+local function run_entry(job)
+ local intent = parse_invocation_intent(job.args)
+ local boundaries = new_application_boundaries(
+ ya.input,
+ apply_find,
+ commit,
+ function()
+ error("yazi-enter: target dispatch is owned by the commit transaction", 0)
+ end
+ )
+ return run_selection_session(intent, boundaries)
+end
+
return {
entry = function(_, job)
- return parse_invocation_intent(job.args)
+ return run_entry(job)
end,
}