Skip to content

amulecmd: expose search filters (type, extension, availability, size) - #542

Merged
mrjimenez merged 2 commits into
amule-project:masterfrom
got3nks:feature/amulecmd-search-filters
May 11, 2026
Merged

amulecmd: expose search filters (type, extension, availability, size)#542
mrjimenez merged 2 commits into
amule-project:masterfrom
got3nks:feature/amulecmd-search-filters

Conversation

@got3nks

@got3nks got3nks commented May 8, 2026

Copy link
Copy Markdown
Contributor

Closes #395.

Motivation

amulecmd help search exposes only the three search modes (global, local, kad) plus a free-text query. The advanced filters the GUI uses (file type, extension, availability, min/max size) are already implemented end-to-end on the EC layer — CEC_Search_Tag accepts all of them, the GUI populates them, the daemon honors them — but the CLI was passing empty defaults, so CLI users have no way to narrow searches like the GUI can.

Change

src/TextClient.cpp:

  • Add a small inline parser that extracts optional --type / --extension / --avail / --min-size / --max-size flags from the search arguments. Flags can appear before, after, or interleaved with the keyword(s); unrecognized tokens are joined as the search query.
  • Wire the parsed values into the existing CEC_Search_Tag constructor instead of the previously-hardcoded empty defaults.
  • Bump the local min_size / max_size types from uint32 to uint64 to match the EC tag — the previous code silently capped sizes at 4 GiB even though the wire protocol carries 64 bits.
  • Fix a pre-existing typo (extentionextension) in the local variable shadowing the parameter name.

docs/man/amulecmd.1 and po/amule.pot: document the new flags.

Examples

amulecmd -P <pwd> -c "search global linux iso --type Iso --min-size 100M"
amulecmd -P <pwd> -c "search kad amule --extension iso"
amulecmd -P <pwd> -c "search global ubuntu --avail 20 --max-size 5G"

amulecmd help search prints the full filter syntax with examples.

Localization

Only the English man page is updated — the localized variants (amulecmd.de.1, .es.1, .fr.1, .hu.1, .it.1, .ro.1, .ru.1, .tr.1, .zh_TW.1) need follow-up translation work for the new section. Until that lands, users invoking man amulecmd under those locales won't see the new filter syntax in the manpage; the runtime help (amulecmd help search) is gettext-driven and falls back to English where translations are missing, so the CLI itself stays usable everywhere.

The new wxTRANSLATE-wrapped strings have been added to po/amule.pot. The per-language .po files are intentionally left alone — msgmerge will mark the new strings as untranslated on the next sync, which is the standard gettext flow.

Testing

Verified end-to-end on macOS 26.4 / Apple Silicon against a running aMule build of master, ed2k Global search via a connected server:

Test Filter Results returned
1 none 561
2 --type Iso 137
3 --min-size 500M 144

Sample entries from test 2 are all .iso filenames; sample entries from test 3 all show file sizes ≥ 500 MiB. Filters reach the daemon, are applied, and reduce the result set as expected.

Also verified:

  • help search displays the new long-form documentation correctly.
  • Filters before / after / interleaved with the keyword all work.
  • Invalid inputs (missing keyword, missing flag value, bad size suffix) are rejected with a clear error and Type 'help search' to get more help.
  • 64-bit sizes (e.g. --min-size 8G) flow through to the EC tag without truncation.

Compatibility

No API changes. Existing search global X / search local X / search kad X calls continue to work exactly as before — the new flags are purely additive and optional.

got3nks added 2 commits May 8, 2026 21:30
… via flags

Wires the existing CEC_Search_Tag filter parameters through to the CLI.
The EC packet has long supported file_type / extension / availability
/ min_size / max_size; the GUI populates them but amulecmd was passing
empty defaults. Add a small inline parser that strips optional flags
out of the search arguments:

    search <global|local|kad> [--type T] [--extension E] [--avail N]
        [--min-size N[KMG]] [--max-size N[KMG]] keyword [keyword ...]

Sizes accept binary-multiplier suffixes (K=1024, M=K*1024, G=M*1024)
or no suffix for bytes; min-size/max-size are wired through as uint64
to match the underlying EC tag (the previous uint32 locals capped
sizes at 4 GiB even though the EC tag itself is 64-bit).

Also fixes a typo ("extention" -> "extension") in the local
variable that was already shadowing the parameter name.
Update docs/man/amulecmd.1 (English) with the new --type / --extension /
--avail / --min-size / --max-size flags, and add the new translatable
strings to po/amule.pot.

The localized man pages (amulecmd.de.1, amulecmd.es.1, amulecmd.fr.1,
amulecmd.hu.1, amulecmd.it.1, amulecmd.ro.1, amulecmd.ru.1,
amulecmd.tr.1, amulecmd.zh_TW.1) are intentionally left at their
current state — the new sections need to be added in each language
when translator capacity is available. Users invoking man amulecmd
under those locales will not see the new filter syntax until that
follow-up lands. Runtime help (`amulecmd help search`) is documented
via gettext and falls back to English on locales that haven't picked
up the new strings yet, so the CLI itself stays usable everywhere.
@mrjimenez
mrjimenez merged commit 47104ef into amule-project:master May 11, 2026
12 checks passed
@got3nks
got3nks deleted the feature/amulecmd-search-filters branch May 11, 2026 08:00
got3nks added a commit to got3nks/amule that referenced this pull request Jul 21, 2026
…ale daemons (amule-project#542)

A headless amuled started without LANG / LC_* (systemd, Docker) runs under
the POSIX/C locale, whose ASCII codeset cannot represent accented or other
non-ASCII UTF-8 filesystem paths. wxConvFileName then fails to open them, so
an accented shared directory silently becomes invisible to the file scan —
reproduced on glibc: `LC_ALL=C` finds 0 files in an accented share where a
UTF-8 locale finds them. This newly bites the remote shared-folder config
(amule-project#530), whose whole point is configuring a headless core, but it affects all
of amuled's non-ASCII file handling.

aMuleInitLocale() now promotes LC_CTYPE to UTF-8 (C.UTF-8, falling back to
en_US.UTF-8) when the resolved codeset is bare ASCII, and exports it so the
promotion survives wx re-resolving the locale from the environment during
app init — a plain setlocale() alone is undone there. The guard is the
codeset itself, so a deliberate UTF-8 or latin1 locale is never overridden,
and musl (already UTF-8 in its C locale) never triggers it. Windows is exempt
(wide-char filesystem APIs).

Verified on an ARM64 glibc VM: with the fix an accented shared folder is
found under a bare environment, an explicit `LC_ALL=C`, and healthy UTF-8
locales alike, with no change for a real locale (it_IT.UTF-8).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

amulecmd search question

2 participants