How vncsmnl/rwx works
Purpose and Runtime
rwx is a Unix-only Rust terminal UI for browsing files and changing permissions, special mode bits, and ownership. It runs as a native CLI binary using Ratatui for rendering and Crossterm for terminal input/control; filesystem mutation ultimately relies on Unix permission and ownership operations.
Core manifest and binary entry point:
• Cargo.toml
• src/main.rs
Startup, CLI, and Terminal Lifecycle
main parses an optional target path and recursive flag, determines whether to begin in browser or editor mode, initializes terminal raw/alternate-screen behavior, and drives the render/event loop. It also installs panic recovery so terminal state is restored after unexpected failures.
Primary entry:
• src/main.rs
Application State and Mode Control
The application model owns navigation state, selected filesystem target, editor fields, focus/input state, pending changes, validation results, modal/status messaging, and recursive-operation selection. It controls transitions between browser mode and permission-editor mode, including returning from an editor target to directory navigation.
Central state/control boundary:
• src/app.rs
• src/main.rs
Filesystem Browser and Target Inspection
The browser reads directory contents, supports selection and directory traversal, and opens either selected entries or the current directory for editing. Target inspection obtains metadata needed to display file type, size, mode, current owner/group, and editable permissions. This is the boundary between the interactive state model and the local Unix filesystem.
Relevant implementation:
• src/app.rs
Permission Representation and Editing Rules
A dedicated permission domain layer converts among Unix mode bits, octal input, checkbox/grid state, and symbolic display strings. It includes regular rwx bits plus SetUID, SetGID, and sticky bits, allowing the UI and mutation layer to work from a consistent permission model.
Permission domain:
• src/permissions.rs
• src/app.rs
Ownership Validation and Change Application
Editor input validates owner and group names against local system identities before applying changes. Applying commits pending permission and ownership edits to the selected path; recursive mode walks a directory tree and applies the requested mutations to nested files and directories. Failures and completion status flow back into application state for UI feedback.
Mutation and traversal boundary:
• src/app.rs
• src/permissions.rs
TUI Rendering and Input Feedback
The UI module is a presentation layer over application state. It renders the file browser, permissions grid, octal and ownership inputs, previews, focus indicators, actions, and status/modal feedback. Keyboard events are interpreted by the main/application control flow, then cause state changes and redraws rather than directly embedding filesystem behavior in the renderer.
Presentation layer:
• src/ui.rs
• src/main.rs
• src/app.rs
Distribution
The project is packaged as a Cargo crate and released as native binaries/installers. Release automation is defined in:
• .github/workflows/release.yml
• Cargo.toml
• dist-workspace.toml
Main entry points: main.rs CLI and event loop · app.rs Ownership and change editor · release.yml Release automation · ui.rs TUI presentation
Components 14
Terminal Runtime
- CLI and event loop · Parses startup options and owns terminal lifecycle.
src/main.rs - Terminal control · Provides rendering surface, raw mode, alternate screen, and events.
- Panic recovery · Restores terminal state after unexpected failure.
src/main.rs - TUI presentation · Renders browser, editor controls, previews, and status feedback.
src/ui.rs
Application Core
- Application state · Owns navigation, editing, focus, pending changes, and feedback.
src/app.rs - Browser/editor modes · Transitions between directory navigation and target editing.
src/app.rs - Directory browser · Lists directories, tracks selection, and chooses edit targets.
src/app.rs - Permission domain · Converts Unix bits, octal input, grid state, and symbolic display.
src/permissions.rs - Ownership and change editor · Validates identities and prepares permission or ownership changes.
src/app.rs
Unix Filesystem
- Local Unix filesystem · Supplies metadata and receives permission and ownership mutations.
- Recursive apply · Walks directory trees to apply requested mutations.
src/app.rs
Distribution
- Cargo crate · Builds the native rwx binary.
Cargo.toml - Release automation · Publishes native binaries and installers.
.github/workflows/release.yml - Distribution workspace
dist-workspace.toml
Connections 19
- Cargo crate → CLI and event loop: builds
- CLI and event loop → Terminal control: initializes
- CLI and event loop → Panic recovery: installs
- Terminal control → CLI and event loop: input events
- CLI and event loop → Application state: drives
- Application state → Browser/editor modes: controls
- Browser/editor modes → Directory browser: browser mode
- Browser/editor modes → Ownership and change editor: editor mode
- Directory browser → Local Unix filesystem: lists and inspects
- Directory browser → Ownership and change editor: opens target
- Ownership and change editor → Permission domain: uses permission model
- Permission domain → Local Unix filesystem: maps mode changes
- Ownership and change editor → Local Unix filesystem: validates identities and applies changes
- Ownership and change editor → Recursive apply: when recursive
- Recursive apply → Local Unix filesystem: walks and mutates
- Application state → TUI presentation: provides state
- TUI presentation → Terminal control: renders to
- Release automation → Cargo crate: packages
- Release automation → Distribution workspace: uses