mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-05 18:56:13 +00:00
refactor!: Migrate runners cmd from string to argv (#134)
Migrate command execution to structured argv lists across the plugin, replacing shell-string command construction with `vim.system` argv execution. The runner API now exposes argv-based execution as the default path:
- `runner.execute_command` -> `runner.execute`
- `runner.execute_command_async` -> `runner.execute_async`
- `runner.execute_command_raw` -> `runner.execute_raw`
- `runner.execute_command_raw_async` -> `runner.execute_raw_async`
- `runner.execute_command_sync` was removed; use `runner.execute` and handle the result directly
BREAKING CHANGES:
- `cmd.new({ args = ... })` now requires `args` as `string[]` argv tokens, not a single string.
- `cmd.log({ ... })` now uses `raw_flags` as `string[]` for raw passthrough flags; `raw = "..."` is no longer supported.
- Direct users of `jj.core.runner` must migrate from the old `execute_command*` string helpers to the new argv-based `execute*` helpers.
This commit is contained in:
@@ -2,7 +2,11 @@ local M = {}
|
||||
|
||||
local utils = require("jj.utils")
|
||||
local terminal = require("jj.ui.terminal")
|
||||
local jj_args = require("jj.core.args")
|
||||
|
||||
--- Build the jj split command based on the provided options.
|
||||
---@param opts jj.cmd.split.opts
|
||||
---@return string[] The constructed jj split command.
|
||||
local function build_split_command(opts)
|
||||
local args = { "jj", "split" }
|
||||
|
||||
@@ -25,11 +29,11 @@ local function build_split_command(opts)
|
||||
|
||||
if opts.filesets then
|
||||
for _, fileset in ipairs(opts.filesets) do
|
||||
table.insert(args, utils.escape_fileset(fileset))
|
||||
table.insert(args, jj_args.fileset(fileset))
|
||||
end
|
||||
end
|
||||
|
||||
return table.concat(args, " ")
|
||||
return args
|
||||
end
|
||||
|
||||
--- Split natively
|
||||
@@ -47,6 +51,8 @@ function M.split(opts)
|
||||
return
|
||||
end
|
||||
|
||||
--- Run the jj split command in a floating terminal
|
||||
---@param cmd string[]
|
||||
local function run_split(cmd)
|
||||
terminal.run_floating(cmd, nil, {
|
||||
title = " JJ Split ",
|
||||
|
||||
Reference in New Issue
Block a user