Skip to content

Conversation

@tomjn
Copy link
Contributor

@tomjn tomjn commented Dec 30, 2025

Main goal here is to add features so that when using vagrant we don't need to trigger a sudo call if we don't have to. That means checks and batch operations. Likewise accounting for if the user walks away and we prompt them for a sudo password, then other programs change the hosts file while we're waiting for permission to make changes

This depends on goodhosts/hostsfile#57

Features added:

  • Extended check command to support batch checking: check <IP> <host1> <host2>...
  • Added --quiet flag for check command (only return exit codes)
  • Added --any flag for check command (match ANY instead of ALL hosts)
  • Added --backup global flag to create backup before modifying hosts
  • Added --safe global flag to detect concurrent modifications
  • Added flushHostsfile() helper that implements backup and safety checks

Command updates:

  • add, remove, clean now use flushHostsfile() for safe writes
  • Backward compatible: single-arg check behavior preserved

Dependencies:

  • Updated go.mod to use local hostsfile library with improvements

Exit codes:

  • 0: Success (host(s) found or operation completed)
  • 1: Check failed (host not found)
  • 2: Invalid arguments

Features added:
- Extended check command to support batch checking: `check <IP> <host1> <host2>...`
- Added --quiet flag for check command (only return exit codes)
- Added --any flag for check command (match ANY instead of ALL hosts)
- Added --backup global flag to create backup before modifying hosts
- Added --safe global flag to detect concurrent modifications
- Added flushHostsfile() helper that implements backup and safety checks

Command updates:
- add, remove, clean now use flushHostsfile() for safe writes
- Backward compatible: single-arg check behavior preserved

Dependencies:
- Updated go.mod to use local hostsfile library with VVV improvements

Exit codes:
- 0: Success (host(s) found or operation completed)
- 1: Check failed (host not found)
- 2: Invalid arguments

This enables VVV vagrant plugin to:
- Check hosts without sudo (read-only operation)
- Only request sudo when hosts are actually missing
@Mte90
Copy link
Member

Mte90 commented Jan 5, 2026

To me make sense, what do you think @luthermonson?

@luthermonson
Copy link
Contributor

great feature, huge fan of this. can you fix the lint error and we'll get this merged

@tomjn
Copy link
Contributor Author

tomjn commented Jan 5, 2026

@luthermonson this is blocked by goodhosts/hostsfile#57, once that's merged and released this PR can be updated to use that which will fix CI

@luthermonson
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants