ventoy / Ventoy

A new bootable USB solution.
https://www.ventoy.net
GNU General Public License v3.0
62.04k stars 4.04k forks source link

Regex support for menu aliases #579

Closed victorbnl closed 2 years ago

victorbnl commented 3 years ago

I use Ventoy for a long time now and a functionnality I always missed would be a support for wildcards or even whole regex. It would be better to be able to make aliases for manjaro-xfce-*.iso instead of manjaro-xfce-20.1.2-201019-linux58.iso

Because now if you download a new version of Manjaro in this case you need to update the config with the exact name which is very redundant when you put new ISOs.

Another functionnality would be capture groups for example

{
  "image": "manjaro-(.+?)-(.+?)-.*.iso"
  "key": "Manjaro \1 \2"
}

would transform manjaro-xfce-20.1.2-201019-linux58.iso into Manjaro xfce 20.1.2

ventoy commented 3 years ago

Well, I think menu alias is only something about the menu display name. It does not affect main function. And menu alias is a very lightweight plugin, so regex match will be too complex and will reduce the matching efficiency.

victorbnl commented 3 years ago

Yes I understand but would It be really that slow? Wouldn't it be valuable to have a bit more of latency, having a functionnality I think everyone would use and that is incredibly convenient to have?

ghost commented 3 years ago

And menu alias is a very lightweight plugin, so regex match will be too complex and will reduce the matching efficiency.

Hi, if not RegEx (I hate that as you can tell from my username), would you please cousider wildcard support?

A minimum support for most common wildcards, i.e. asterisk (*) and question mark (?), would make a difference.

I have a script to update ventoy.json but it just seems kinda weird.

ventoy commented 3 years ago

You can test with this CI release: https://github.com/ventoy/Ventoy/actions/runs/780095502

I add a simple match feature. But for simplicity, the fuzzy matching is much different with our common usage.

A * is fixed to match only 1 character, if you want to match multiple characters, you need to write multiple *

Sample :

{
    "menu_alias" : [
        {
            "image": "/Ubuntu_based/KDEneon/neon-user-********.iso",
            "alias": "KDEneon - Stable"
        }
    ]
}
ventoy commented 2 years ago

This is an old issue. I will close it now. If you still have problem with latest Ventoy release, you can reopen the issue.

ifohancroft commented 1 year ago

I'd also love to be able to match multiple characters with a single '*' character, or even have regex support.

Right now Parrot OS's version for example is 5.3, but who knows what their version number policy is, maybe it would reach version 5.10 then we'll need to change the config file.

Same problem with Windows. The current Windows 11 ISO is called Win11_22H2_English_x64v2, but what if the version (22H2) gets longer or shorter, or they drop the v2 at the end?

tefod-zz commented 3 months ago

In file names, there are usually indicators (such as w10, w11, x64, etc.) included and, of course, version numbers. These change with each version, making it a tedious task to update the 'menu alias' every time. Therefore, I would greatly appreciate an optional regex feature. A wildcard is a character used to represent one or any number of characters in a string, and it should be possible to use it at the beginning and/or the end. The current Fussy search creates more problems than it solves 🤷‍♂️

Performance issues should not arise from this. Ultimately, all ISOs/images are searched on the flash drive and likely stored in an array probably. Even if someone has many, it might be around 50. Then another array with the 'alias' database is searched and they get been "mapped". This is not a disk or file operation - just in the RAM. Extending this search with regex should only take a few milliseconds in terms of performance.

victorbnl commented 3 months ago

Instead of regexes and multi-character wildcards, maybe a prefix detection could suffice? If an ISO starts with Win, or Win10 for more precision, we know what OS it’ll turn out to be. If it starts with ubuntu as well. In terms of performance, iterating over a few characters doesn’t look very resource-intensive.

tefod-zz commented 2 months ago

Instead of regexes and multi-character wildcards, maybe a prefix detection could suffice? If an ISO starts with Win, or Win10 for more precision, we know what OS it’ll turn out to be. If it starts with ubuntu as well. In terms of performance, iterating over a few characters doesn’t look very resource-intensive.

Functionally, it would be the same, and we would be very happy about such an update. This way, we wouldn't have to adjust the ISO filenames or change the menu entries with each new version of the ISO.