[PR #46] [MERGED] Add batch check command and safety features to CLI #45

Closed
opened 2026-03-02 05:09:23 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/goodhosts/cli/pull/46
Author: @tomjn
Created: 12/30/2025
Status: Merged
Merged: 1/20/2026
Merged by: @luthermonson

Base: mainHead: feature/batch-check


📝 Commits (2)

  • bbb1441 Add batch check command and safety features to CLI
  • ad09e4a Update hostsfile dependency to v0.1.7

📊 Changes

7 files changed (+112 additions, -23 deletions)

View changed files

📝 cmd/add.go (+1 -1)
📝 cmd/app.go (+31 -0)
📝 cmd/check.go (+72 -10)
📝 cmd/clean.go (+1 -1)
📝 cmd/remove.go (+1 -1)
📝 go.mod (+2 -2)
📝 go.sum (+4 -8)

📄 Description

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 https://github.com/goodhosts/hostsfile/pull/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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/goodhosts/cli/pull/46 **Author:** [@tomjn](https://github.com/tomjn) **Created:** 12/30/2025 **Status:** ✅ Merged **Merged:** 1/20/2026 **Merged by:** [@luthermonson](https://github.com/luthermonson) **Base:** `main` ← **Head:** `feature/batch-check` --- ### 📝 Commits (2) - [`bbb1441`](https://github.com/goodhosts/cli/commit/bbb144176e8c86786320bb4dd8aed910ab36f170) Add batch check command and safety features to CLI - [`ad09e4a`](https://github.com/goodhosts/cli/commit/ad09e4a0fbfa08631bdd1904f305fe9ea4fb9b05) Update hostsfile dependency to v0.1.7 ### 📊 Changes **7 files changed** (+112 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `cmd/add.go` (+1 -1) 📝 `cmd/app.go` (+31 -0) 📝 `cmd/check.go` (+72 -10) 📝 `cmd/clean.go` (+1 -1) 📝 `cmd/remove.go` (+1 -1) 📝 `go.mod` (+2 -2) 📝 `go.sum` (+4 -8) </details> ### 📄 Description 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 https://github.com/goodhosts/hostsfile/pull/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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 05:09:23 +03:00
Sign in to join this conversation.
No labels
bug
bug
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cli#45
No description provided.