Skip to content

feat: Add --exclude option for host exclusion (pdsh -x compatibility)#100

Merged
inureyes merged 3 commits intomainfrom
feature/issue-93-exclude-option
Dec 16, 2025
Merged

feat: Add --exclude option for host exclusion (pdsh -x compatibility)#100
inureyes merged 3 commits intomainfrom
feature/issue-93-exclude-option

Conversation

@inureyes
Copy link
Member

Summary

Add a new --exclude option to bssh that allows users to exclude specific hosts from the target list. This is part of pdsh compatibility mode (Phase 1 of #91).

Changes

CLI Option

  • Added --exclude option with comma-separated value support
  • Supports wildcard patterns using glob matching (e.g., db*, *-backup)
  • Applied after --filter option for precise control

Usage Examples

# Exclude single host
bssh -H "node1,node2,node3" --exclude "node2" "uptime"

# Exclude multiple hosts
bssh -C production --exclude "web1,web2" "apt update"

# Exclude with wildcard pattern
bssh -C production --exclude "db*" "systemctl restart"

# Exclude backup nodes
bssh -C production --exclude "*-backup" "df -h"

Implementation Details

  • New exclude_nodes() function in src/app/nodes.rs
  • Security validations for pattern length, wildcard count, and character restrictions
  • Integration with existing node resolution workflow
  • 17 comprehensive unit tests covering various scenarios

Note

Short option -x is not used due to conflict with existing --no-x11 option. The -x short form will be available in pdsh compatibility mode.

Test Plan

  • All 619 existing tests pass
  • New unit tests for exclusion logic pass
  • Clippy checks pass with no warnings
  • Build succeeds
  • Help text displays correctly

Closes #93

Add a new --exclude option to bssh that allows users to exclude specific
hosts from the target list. This is part of pdsh compatibility mode
(Phase 1 of #91).

Features:
- --exclude option accepts comma-separated list of hosts to exclude
- Supports wildcard patterns using glob matching (e.g., 'db*', '*-backup')
- Works with both -H (direct hosts) and -C (cluster) modes
- Applied after --filter option for precise control
- Comprehensive error handling for excluding all hosts

Note: Short option -x is not used due to conflict with existing --no-x11
option. The -x short form will be available in pdsh compatibility mode.

Closes #93
@inureyes inureyes added type:enhancement New feature or request status:review Under review priority:medium Medium priority issue labels Dec 16, 2025
- Add tests for bracket pattern matching (e.g., [12], [!12])
- Add tests for bracket negation patterns
- Update help text to document matching behavior differences
- Fix misleading comment about ReDoS protection
- Allow '!' character in patterns for negation support
- Add --exclude examples in README.md Multi-Server Mode section
- Add --exclude to Command-Line Options in README.md
- Add --exclude option documentation to manpage with examples
- Update ARCHITECTURE.md with current nodes.rs line count
@inureyes inureyes self-assigned this Dec 16, 2025
@inureyes inureyes merged commit 55fd38d into main Dec 16, 2025
3 checks passed
@inureyes inureyes deleted the feature/issue-93-exclude-option branch December 16, 2025 14:59
@inureyes inureyes added status:done Completed and removed status:review Under review labels Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority issue status:done Completed type:enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add --exclude option for host exclusion (pdsh -x compatibility)

1 participant