-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
Summary
The CLI currently accepts a --remove-from-file argument but doesn't implement the functionality (falls back to TUI with a warning). Implement the feature to allow removing packages listed in a file via command line, similar to the existing --install-from-file functionality.
Files to modify
src/args/definition.rs(around line 142 - replace TODO with implementation)src/args/remove.rs(addhandle_remove_from_filefunction)
Expected behavior
When users run pacsea --remove-from-file packages.txt:
- Read package names from the specified file (one package per line)
- Parse package names (handle comments, empty lines, whitespace)
- Display packages that will be removed
- Show appropriate warnings about package removal
- Prompt for user confirmation (defaulting to No for safety)
- Execute
sudo pacman -Rnswith the package list - Show removal results and check for leftover config files
- Exit immediately (CLI mode, no TUI)
Implementation approach
-
Add remove-from-file handler:
pub fn handle_remove_from_file(file_path: &str) -> ! { // Read packages from file (reuse read_packages_from_file from install.rs) // Validate packages exist // Show removal preview // Get user confirmation // Execute removal }
-
File parsing:
- Reuse
read_packages_from_filefunction fromsrc/args/install.rs - Handle comments (lines starting with #)
- Skip empty lines
- Trim whitespace
- Reuse
-
Package validation:
- Check that packages are actually installed
- Show warnings for packages that don't exist
-
User interaction:
- Display packages to be removed
- Show removal warnings
- Prompt for confirmation (default No)
- Allow cancellation
-
Execution:
- Run
sudo pacman -Rnscommand - Handle success/failure cases
- Check for leftover config directories
- Run
Testing
-
cargo checkpasses -
cargo clippy --all-targets --all-features -- -D warningspasses -
cargo test -- --test-threads=1passes - Test reading packages from file with various formats
- Test handling of comments and empty lines in file
- Test validation of installed packages
- Test user confirmation prompt (yes/no/cancel)
- Test successful package removal
- Test error handling when packages don't exist
- Test config directory detection after removal
- Test file not found error handling
Additional context
Follow the established patterns from:
- File reading:
read_packages_from_fileinsrc/args/install.rs - CLI remove logic:
handle_removeinsrc/args/remove.rs - User prompts:
utils::prompt_user_no_defaultfor safety - Error handling: Use existing i18n strings and tracing
The implementation should be consistent with --install-from-file behavior but follow remove-specific safety practices (confirmation defaults to No, clear warnings about data loss).
File format should match install-from-file:
# Package list for removal
package1
package2 # comment
# commented out package
package3
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed