Skip to content

Conversation

sxyazi
Copy link
Owner

@sxyazi sxyazi commented Feb 6, 2025

Follow up to #2298

In #2298, all commands now support passing raw text as the last argument after --, without requiring any escaping.

This PR aims to simplify argument passing for plugin commands by deprecating the --args option in the plugin command.

Instead, the new second positional argument represents the list of arguments received by the plugin:

[[manager.prepend_keymap]]
on  = "<C-e>"
- run = "plugin test --args='foo bar'"
+ run = "plugin test 'foo bar'"

With #2298,

[[manager.prepend_keymap]]
on  = "<C-e>"
run = "plugin search --args='--keyword=\'hello world\''"

can now be written as:

[[manager.prepend_keymap]]
on  = "<C-e>"
run = "plugin search -- --keyword='hello world'"

The existing --args option will still be available but will trigger a deprecation warning to ensure a smooth transition.

@sxyazi sxyazi merged commit a847705 into main Feb 6, 2025
6 checks passed
@sxyazi sxyazi deleted the pr-afc451ba branch February 6, 2025 18:51
@sxyazi sxyazi mentioned this pull request Feb 6, 2025
mikavilpas added a commit to mikavilpas/starship.yazi that referenced this pull request Feb 7, 2025
Issue
=====

In yazi 25.2.7, loading the plugin will display a deprecation message.

> The `args` parameter of the `plugin` command has been deprecated.
> Please use the second positional argument of `plugin` instead. For
> example, replace `plugin test --args=foobar` with `plugin test foobar`,
> for your `plugin {}` command. See #2299 for more information:
> sxyazi/yazi#2299

Source code for the message for reference:
https://github.com/sxyazi/yazi/pull/2299/files#diff-12c9a1618a93a5c77e0fb35e602178f0c266b8e4a43d0d578a6aa5e63f5b3c79R33

Solution
========

The deprecation message is confusing because it's aimed at end users,
not plugin developers. It seems to go away if we remove the `args` key
when emitting the `plugin` event.
mikavilpas added a commit to mikavilpas/starship.yazi that referenced this pull request Feb 8, 2025
Issue
=====

In yazi 25.2.7, loading the plugin will display a deprecation message.

> The `args` parameter of the `plugin` command has been deprecated.
> Please use the second positional argument of `plugin` instead. For
> example, replace `plugin test --args=foobar` with `plugin test foobar`,
> for your `plugin {}` command. See #2299 for more information:
> sxyazi/yazi#2299

Source code for the message for reference:
https://github.com/sxyazi/yazi/pull/2299/files#diff-12c9a1618a93a5c77e0fb35e602178f0c266b8e4a43d0d578a6aa5e63f5b3c79R33

Solution
========

The deprecation message is confusing because it's aimed at end users,
not plugin developers. It seems to go away if we remove the `args` key
when emitting the `plugin` event.
mikavilpas added a commit to mikavilpas/starship.yazi that referenced this pull request Feb 8, 2025
Issue
=====

In yazi 25.2.7, loading the plugin will display a deprecation message.

> The `args` parameter of the `plugin` command has been deprecated.
> Please use the second positional argument of `plugin` instead. For
> example, replace `plugin test --args=foobar` with `plugin test foobar`,
> for your `plugin {}` command. See #2299 for more information:
> sxyazi/yazi#2299

Source code for the message for reference:
https://github.com/sxyazi/yazi/pull/2299/files#diff-12c9a1618a93a5c77e0fb35e602178f0c266b8e4a43d0d578a6aa5e63f5b3c79R33

Solution
========

The deprecation message is confusing because it's aimed at end users,
not plugin developers. It seems to go away if we remove the `args` key
when emitting the `plugin` event.
mikavilpas added a commit to mikavilpas/starship.yazi that referenced this pull request Feb 8, 2025
Issue
=====

In yazi 25.2.7, loading the plugin will display a deprecation message.

> The `args` parameter of the `plugin` command has been deprecated.
> Please use the second positional argument of `plugin` instead. For
> example, replace `plugin test --args=foobar` with `plugin test foobar`,
> for your `plugin {}` command. See #2299 for more information:
> sxyazi/yazi#2299

Source code for the message for reference:
https://github.com/sxyazi/yazi/pull/2299/files#diff-12c9a1618a93a5c77e0fb35e602178f0c266b8e4a43d0d578a6aa5e63f5b3c79R33

Solution
========

The deprecation message is confusing because it's aimed at end users,
not plugin developers. It seems to go away if we remove the `args` key
when emitting the `plugin` event.
Rolv-Apneseth pushed a commit to Rolv-Apneseth/starship.yazi that referenced this pull request Feb 8, 2025
Issue
=====

In yazi 25.2.7, loading the plugin will display a deprecation message.

> The `args` parameter of the `plugin` command has been deprecated.
> Please use the second positional argument of `plugin` instead. For
> example, replace `plugin test --args=foobar` with `plugin test foobar`,
> for your `plugin {}` command. See #2299 for more information:
> sxyazi/yazi#2299

Source code for the message for reference:
https://github.com/sxyazi/yazi/pull/2299/files#diff-12c9a1618a93a5c77e0fb35e602178f0c266b8e4a43d0d578a6aa5e63f5b3c79R33

Solution
========

The deprecation message is confusing because it's aimed at end users,
not plugin developers. It seems to go away if we remove the `args` key
when emitting the `plugin` event.
hankertrix added a commit to hankertrix/augment-command.yazi that referenced this pull request Feb 9, 2025
The README for the plugin will not be updated until the pull request
above has made it into the stable version of Yazi.
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Feb 11, 2025
⚠️ **CAUTION: this is a major update, indicating a breaking change!** ⚠️

This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [sxyazi/yazi](https://github.com/sxyazi/yazi) | major | `v0.4.2` -> `v25.2.7` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>sxyazi/yazi (sxyazi/yazi)</summary>

### [`v25.2.7`](https://github.com/sxyazi/yazi/releases/tag/v25.2.7)

[Compare Source](sxyazi/yazi@v0.4.2...v25.2.7)

#### Deprecated

-   `ya.md5()` has been deprecated in favor of the new `ya.hash()`, in sxyazi/yazi#2168
-   The plugin entry file `init.lua` has been deprecated in favor of the new `main.lua`, in sxyazi/yazi#2168
-   `arrow -99999999` and `arrow 99999999` have been deprecated in favor of the new `arrow top` and `arrow bot`, in sxyazi/yazi#2294
-   The `--args` option in the `plugin` command has been deprecated in favor of a new 2nd positional parameter, in sxyazi/yazi#2299
-   The numeric return value of the preloader has been deprecated in favor of a new boolean return value, in sxyazi/yazi#2253

#### The [`mount.yazi`](https://github.com/yazi-rs/plugins/tree/main/mount.yazi) Plugin

For a long time, I've been receiving requests from users for a mount manager, but never had the time to finish it. But now — it's here!

[`mount.yazi`](https://github.com/yazi-rs/plugins/tree/main/mount.yazi) provides disk mount, unmount, and eject functionality:

https://github.com/user-attachments/assets/b97b8156-e7ca-490c-88a2-8624f4190b29

Done in sxyazi/yazi#2199.

#### Simplification of `shell` and `plugin` commands

With sxyazi/yazi#2298, you can now write shell scripts directly after `--` (end of options marker). Everything after `--` will be treated as raw text, so no more escaping is required, greatly simplifying the writing of complex commands.

For example, previously, a simple `echo "hello 'world'"` would look like this:

```toml
[[manager.prepend_keymap]]
on  = "<C-e>"
run = '''
  shell --block 'echo "hello '\''world'\''"'
'''
```

This resulted in nested quotes, which was error-prone and unintuitive.

Now, you can directly include the entire shell script as plain text after `--` without any escaping:

```toml
[[manager.prepend_keymap]]
on  = "<C-e>"
run = '''
  shell --block -- echo "hello 'world'"
'''
```

Similarly, with sxyazi/yazi#2299, the `plugin` command usage has been simplified as well. For instance:

```toml
[[manager.prepend_keymap]]
on  = "<C-e>"
run = "plugin search --args='\'hello world\''"
```

Can now be written as:

```toml
[[manager.prepend_keymap]]
on  = "<C-e>"
run = "plugin search -- 'hello world'"
```

#### Replace Mode and Vim Motions (`W`, `E`, `B`, `^`, `_`) for Inputs

The Input component now supports replace mode and several new Vim motions, including:

-   `W`: Move forward to the start of the next WORD
-   `E`: Move forward to the end of the current or next WORD
-   `B`: Move back to the start of the current or previous WORD
-   `^`: Move to the first non-whitespace character
-   `_`: Move to the first non-whitespace character

Thanks to [@&#8203;dxrcy](https://github.com/dxrcy) for the work in sxyazi/yazi#2143!

#### Package Manager Enhancements

The package manager now supports the following new features:

-   `ya pack -d` to delete a package (thanks [@&#8203;MrAsler](https://github.com/MrAsler), sxyazi/yazi#2181)
-   Support for adding and removing multiple packages with a single command (thanks [@&#8203;evpeople](https://github.com/evpeople), sxyazi/yazi#2257)

#### Support Local `tmux` Image Preview Over SSH

Now, when you start tmux locally, connect to a remote SSH session, and run Yazi on the remote host, you'll get image preview support out of the box.

Done in sxyazi/yazi#2229.

#### New `@since` Plugin Annotation to Specify the Minimum Supported Yazi Version

You can now **optionally** specify the minimum supported Yazi version in your plugin:

```lua
--- @&#8203;since 25.2.7

return {
  entry = function() end
}
```

If specified, and the user's Yazi version is lower than the given version, they will receive an error message preventing the plugin from running accidentally.

Done in sxyazi/yazi#2290

#### New `ya.confirm()` API

The new `ya.confirm()` API allows you to show a confirmation prompt to the user:

```lua
local answer = ya.confirm {
  pos = { "center", w = 40, h = 10 },
  title = "Test",
  content = "Hello, World!",
}
```

You can also apply a UI element to the title and content to customize the appearance:

```lua
local answer = ya.confirm {
  pos = { "center", w = 40, h = 10 },
  title = ui.Line("Test"):fg("yellow"):bold(),
  content = ui.Text("Hello, World!"):bg("red"):fg("#ffffff"),
}
```

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNjQuMSIsInVwZGF0ZWRJblZlciI6IjM5LjE2NC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
wincent added a commit to wincent/wincent that referenced this pull request Feb 17, 2025
Zen-Path pushed a commit to Zen-Path/flexycon that referenced this pull request Feb 24, 2025
Zen-Path pushed a commit to Zen-Path/flexycon that referenced this pull request Feb 25, 2025
h-hg added a commit to h-hg/yamb.yazi that referenced this pull request Feb 28, 2025
Rename to main.lua and update commands
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 9, 2025
Zen-Path pushed a commit to Zen-Path/flexycon that referenced this pull request Apr 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant