goodhosts/cli

More clean options

Closed this issue · 3 comments

tomjn commented

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

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

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

tomjn commented

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