Add CLI flag surface: -rename/--format/--db/--action/--conflict/-non-strict/-h

Ports FileBot's net.filebot.cli flag surface so Aurora Curator can be scripted,
not just driven through the GUI. Argument parsing and file-expansion are pure
Rust in aurora-curator-core::cli (14 unit tests, no Tauri/network dependency);
orchestration lives in src-tauri/src/cli.rs, which reuses the exact same
binding vocabulary the GUI's RenamePanel.tsx builds client-side and the exact
same TMDB/TVmaze season-caching lookup fetch_metadata already uses, so a
naming scheme renders identically whether it's typed into the app or passed
via --format.

main.rs branches to CLI mode before any Tauri App/window is built at all,
using tauri::async_runtime::block_on to drive the async metadata lookups
(confirmed safe standalone by reading Tauri's own async_runtime.rs) and a
hand-rolled settings::cli_tmdb_token() that replicates Tauri's own
app_config_dir() computation (dirs::config_dir().join(identifier), pinned
against tauri.conf.json by a new test) so a token saved through the GUI's
Fetch Data Settings is found from the CLI path too - the CLI still never
accepts a token as an argument.

Deliberately not ported: --output <dir> (the rename engine's safety
invariant against escaping the source directory tree would need to be
relaxed) and -non-strict is accepted as a no-op (local matching has no
confidence score to loosen).

16 new tests in src-tauri (10 in cli.rs, 1 pinning settings::
APP_CONFIG_IDENTIFIER) plus 14 in aurora-curator-core's cli module - full
workspace suite is 113 passing. README updated with a new "Command-line
usage" section and roadmap item 6 marked done for the CLI surface.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QLbx8ov7zMcdDPEqQm4Y98
This commit is contained in:
Renamr Scaffold
2026-08-29 11:30:51 +00:00
co-authored by Claude Sonnet 5
parent 5763c6313b
commit 22a3da9f6f
9 changed files with 1108 additions and 26 deletions
+69 -9
View File
@@ -34,7 +34,10 @@ rest of FileBot's full media-metadata bindings (real probed video/audio stream i
are not yet ported. The Align Up/Down buttons reorder the (shared) file list — the two
panes always stay positionally paired — and up to 9 naming schemes can be saved as
presets, recalled with a click or a `1`-`9` keypress (persisted locally, same pattern as
Settings/History). See "Porting roadmap" below.
Settings/History). The app can also be driven entirely from the command line —
`aurora-curator -rename --format "<naming scheme>" [options] <file-or-folder>...` — for
scripting batch renames without opening the window at all; see "Command-line usage"
below. See "Porting roadmap" below.
The naming scheme is fully user-editable from the app (the "Naming Scheme" button next
to the New Names list) — the default is `{show name} - {season number}x{episode
@@ -141,11 +144,14 @@ crates/aurora-curator-core/ Pure Rust core: naming-expression engine (ported),
rename engine (`rename/` — Move/Copy/Symlink actions,
Skip/Auto-number/Override conflict policies, can also organize
into (auto-created) subfolders when
the naming scheme includes `/`) — and a rename history/undo log
the naming scheme includes `/`), a rename history/undo log
(`history/`, a partial `HistoryDialog` port, undo-aware of which
action produced each batch). Not yet ported: full media metadata
bindings, other web datasource clients (TheTVDB/AniDB/OMDb/etc).
No Tauri dependency, so it builds and unit-tests standalone.
action produced each batch), and pure `-rename` command-line
argument parsing/file expansion (`cli/` — no Tauri or network
dependency at all, see "Command-line usage" below). Not yet
ported: full media metadata bindings, other web datasource
clients (TheTVDB/AniDB/OMDb/etc). No Tauri dependency, so it
builds and unit-tests standalone.
src-tauri/ Tauri app shell: exposes aurora-curator-core as commands to the frontend
(naming-scheme rendering, filename matching for both TV and
movies, metadata fetch — `metadata.rs` for TV episodes (against
@@ -154,8 +160,12 @@ src-tauri/ Tauri app shell: exposes aurora-curator-core as commands
plan, native file/folder dialogs, drag-and-drop expansion), plus
`settings.rs` (TMDB token, and which TV metadata source Fetch Data
uses), `history.rs` (rename history/undo
log), and `presets.rs` (up to 9 saved naming schemes) — all three
stored as JSON in the OS app-config directory — app
log), `presets.rs` (up to 9 saved naming schemes) — all three
stored as JSON in the OS app-config directory — `cli.rs` (the
`-rename` command-line mode's orchestration: builds and executes a
rename plan against `aurora-curator-core::cli`'s parsed arguments,
with no Tauri `App`/window ever created for it — `main.rs` branches
to it before the GUI is touched at all), and app
metadata/icons/window config (tauri.conf.json).
src/ React + TypeScript UI (Vite). Faithful recreation of the original
two-pane rename screen (Aurora theme) wired to real file loading,
@@ -221,6 +231,49 @@ A batch of TV-only files can run entirely on TVmaze with no token configured at
batch containing any movies still needs the TMDB token regardless of which TV source is
selected.
## Command-line usage
The same binary that opens the GUI can also run a batch rename straight from a script or
terminal — a port of FileBot's `net.filebot.cli` flag surface (`-rename`, `--format`,
`--db`, `--action`, `--conflict`), with a couple of deliberate differences noted below.
Passing `-rename` (or `-h`/`--help`) on the command line skips the window entirely:
```sh
aurora-curator -rename --format "{show name} - {season number}x{episode number} - {episode name}" \
--action move --conflict skip ~/Downloads/some-show/
```
- `--format "<naming scheme>"` (required) — the same expression syntax as the GUI's
Naming Scheme field: FileBot short names (`{n}`, `{s00e00}`, `{t}`), human-readable
aliases (`{show name}`, `{episode name}`, `{movie name}`, `{resolution}`, `{video
codec}`, `{release group}`, …), or real Rhai script. `{name}`/`{ext}` fall back to the
file's own current filename/extension when nothing else matched it.
- `--db <tmdb|tvmaze>` (optional) — resolves TV episodes against that online source
before rendering names, the command-line equivalent of clicking "Fetch Data" after
Match. Movies are only looked up online when this is `tmdb` — TVmaze has no movie
catalog, and with no `--db` at all every file uses local filename matching only, same
as Match without Fetch Data in the GUI. `--db tmdb` needs a TMDB token that's already
been saved through the app's own Fetch Data Settings at least once — **the CLI never
accepts an API token as an argument**, so there's nothing secret to leak into your
shell history or a script.
- `--action <move|copy|symlink|test>` (default `move`) — what to do at each computed
target; `test` prints the full plan and touches nothing on disk, useful for checking a
naming scheme before committing to it.
- `--conflict <skip|auto-number|override>` (default `skip`, `autonumber`/`auto` also
accepted) — what happens when the computed target already exists.
- `-non-strict` — accepted for compatibility with existing FileBot scripts, but is a
genuine no-op here: the local matcher has no confidence score to loosen, and online
disambiguation (`similarity::best_title_match`) always runs regardless of this flag.
- Every remaining argument is treated as an input file or folder; folders are expanded
recursively (hidden files/dotfolders skipped), matching exactly what the GUI's own
"Select Folder…" and drag-and-drop do.
Deliberately **not** ported: FileBot's `--output <dir>` flag. The rename engine is
scoped, as a safety invariant, to never move a file outside its own source directory
tree (see "Organizing into subfolders" above) — a naming scheme's own `/` already covers
organizing into a subfolder, and relaxing that invariant just for `--output` wasn't
judged worth it.
## Porting roadmap (not yet done)
Roughly in priority order — each references the original FileBot source file it's
@@ -291,8 +344,15 @@ ported from, for anyone picking this up:
first free slot), or Override (replaces the conflicting file outright — the one
irreversible option, called out with red styling in the UI; undoing that batch later
restores the *source*, never what got overwritten, since undo always uses its own
fixed skip-on-conflict policy no matter which policy the original rename used). Not
yet done: the CLI flag surface itself.
fixed skip-on-conflict policy no matter which policy the original rename used). The
CLI flag surface is done too — `-rename`/`--format`/`--db`/`--action`/`--conflict`/
`-non-strict`/`-h` (`crates/aurora-curator-core/src/cli` for pure argument parsing and
directory expansion, `src-tauri/src/cli.rs` for the orchestration — local matching,
optional TMDB/TVmaze lookup, and the actual rename, all without ever constructing a
Tauri `App`); see "Command-line usage" above. `--output <dir>` and `-get-subtitles`/
`-script`/the rest of FileBot's non-rename CLI modes are not ported — `-get-
subtitles` and `-script` have no analog yet since subtitle-fetching and a script-mode
runtime aren't built at all.
7. **The rest of the UI** — the Rename panel (file loading, drag-drop, live preview,
local TV/movie matching, confirmed rename with per-item exclude, rename history/undo,
Align Up/Down reordering, naming-scheme Presets with `1`-`9` hotkeys) is built; the