[GH-ISSUE #21] More clean options #10

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

Originally created by @tomjn on GitHub (Oct 18, 2020).
Original GitHub issue: https://github.com/goodhosts/cli/issues/21

The clean subcommand does the following:

Clean the hostsfile by doing: remove dupe IPs, for each IPs remove dupe hosts and sort, sort all IPs, split hosts per OS limitations

However, some of these may be undesirable. For example sorting and merging could interfere with other software that relies on modifying the hosts file.

For example:

::1 localhost testwplocaltest.local www.testwplocaltest.local #Local Site Local Site

Here several items the OS added to the hosts file have been merged with entries added by the WP Engine Local software. If that software was lazy it might remove that entire line when removing that site.

Similarly a group of docker domains got smushed together on the same line with several other domains because they all used 127.0.0.1, and the comments surrounding them have vanished.

So, it would be good to have separate options/flags for:

  • merging entries on to the same line
  • de-duping domains
  • de-duping lines
  • etc
Originally created by @tomjn on GitHub (Oct 18, 2020). Original GitHub issue: https://github.com/goodhosts/cli/issues/21 The `clean` subcommand does the following: > Clean the hostsfile by doing: remove dupe IPs, for each IPs remove dupe hosts and sort, sort all IPs, split hosts per OS limitations However, some of these may be undesirable. For example sorting and merging could interfere with other software that relies on modifying the hosts file. For example: ``` ::1 localhost testwplocaltest.local www.testwplocaltest.local #Local Site Local Site ``` Here several items the OS added to the hosts file have been merged with entries added by the WP Engine Local software. If that software was lazy it might remove that entire line when removing that site. Similarly a group of docker domains got smushed together on the same line with several other domains because they all used `127.0.0.1`, and the comments surrounding them have vanished. So, it would be good to have separate options/flags for: - merging entries on to the same line - de-duping domains - de-duping lines - etc
kerem closed this issue 2026-03-02 05:09:09 +03:00
Author
Owner

@luthermonson commented on GitHub (Oct 18, 2020):

how about a clean -A or --all for doing all the stuff and then ill add --with options for each flavor of cleaning?

<!-- gh-comment-id:711336802 --> @luthermonson commented on GitHub (Oct 18, 2020): how about a clean -A or --all for doing all the stuff and then ill add --with options for each flavor of cleaning?
Author
Owner

@luthermonson commented on GitHub (Oct 18, 2020):

@tomjn can you give me example hosts file so i can check the comment mashing and doman smushing?

<!-- gh-comment-id:711337445 --> @luthermonson commented on GitHub (Oct 18, 2020): @tomjn can you give me example hosts file so i can check the comment mashing and doman smushing?
Author
Owner

@tomjn commented on GitHub (Oct 18, 2020):

how about a clean -A or --all for doing all the stuff and then ill add --with options for each flavor of cleaning?

This sounds good :)

@tomjn can you give me example hosts file so i can check the comment mashing and doman smushing?

I did but it got cleaned up, I imagine something like this would face the problem:

127.0.0.1 localhost

# XYZ BEGIN
127.0.0.1 a.test
127.0.0.1 b.test
127.0.0.1 c.test
# XYZ END

127.0.0.1 vagrant.test # Auto added ABC123HASH
127.0.0.1 tomsite.com
<!-- gh-comment-id:711370892 --> @tomjn commented on GitHub (Oct 18, 2020): > how about a clean -A or --all for doing all the stuff and then ill add --with options for each flavor of cleaning? This sounds good :) > @tomjn can you give me example hosts file so i can check the comment mashing and doman smushing? I did but it got cleaned up, I imagine something like this would face the problem: ``` 127.0.0.1 localhost # XYZ BEGIN 127.0.0.1 a.test 127.0.0.1 b.test 127.0.0.1 c.test # XYZ END 127.0.0.1 vagrant.test # Auto added ABC123HASH 127.0.0.1 tomsite.com ```
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#10
No description provided.