Comments (30)
@Mte90 @theMikeD let's do it, if we do some sort of #MANAGED BY GOODHOSTS
comment block and only change entries in there it would make the most sense but i feel this requires a 1.1.x version bump, agree?
from cli.
i dont think you can use the --clean
functionality with a rig like mamp then, the only way to get here is through a clean flag right? i am not missing something that got you here via other use?
from cli.
I think this needs migrating to the vagrant
repo at https://github.com/goodhosts/vagrant
from cli.
ohhh that makes sense, ill copy/paste and link it and close this
from cli.
To me the issue is not just the plugin that does a clean but the fact that the clean command, cleans all the file and just the parts that are involved with goodhosts.
Clean command was implemented to avoid multiple injection of the same rule by goodhosts as a previous ticket so is a problem in both the projects @luthermonson
from cli.
you think there should be a #goodhosts
comment or something and just keep everything 100% separate from everyone else?
from cli.
yes in this way the user can use clean without worrying.
from cli.
Yes to me is good so I can do a new release of the plugin with that and add a flag to enable or not the clean at all.
from cli.
This sounds good!
from cli.
Whats the next step?
from cli.
find time to add the feature :D PRs welcome~
from cli.
from cli.
@luthermonson any update or technical direction? You have willing contributors with the time to make the change, who don't know what to do. I'd really like to be able to write a PR but what would that PR look like?
from cli.
@tomjn this is what i want.. open to feedback
- all code for doing this should be in the cli, the hostsfile package should just be to parse a hosts file to types. this is logic around what to do with the hostsfile after that is done so this code should be here in this repo, can try doing a first round of this have a line type that uses hostsfile.Line and includes a bool which is we check if we manage the line or not.
- easiest thing is probably a string to match in comment per line like MAMP does, for example as long as it contains
goodhosts
in the comment we assume it was meant for our cli, just need a something simple likestrings.Contains("goodhosts", comment)
. e.g. we'd manage all of these lines
127.0.0.1 myhost anotherhost #goodhosts
192.168.0.2 dev-server1 #my comment here goodhosts
192.168.0.3 dev-server2 #goodhosts my comment here
- make sure when we add an entry with the add subcommand we need to make sure the comment gets put in place as well
- might find it annoying if the goodhosts managed lines are all over the file, might want clean to group them together
- dont forget the tests!
from cli.
Maybe we can just revert the clean imperative until there is a way to turn it off?
from cli.
@theMikeD that doesn't make sense in the context of this repo, for Goodhosts CLI, it would be easier to not use --clean
than it would be to remove the feature.
I think there's been some misunderstanding as to what goodhosts is on your part:
- goodhosts cli, a golang command line program for adding and removing things from the hosts file
- vagrant-goodhosts, a vagrant plugin that uses goodhosts to add hosts as requested by a vagrant project
- VVV, a vagrant project that uses vagrant goodhosts in place of vagrant hostsupdater
This is the goodhosts cli repo, so reverting the --clean
parameter means removing that feature. Unless you meant make vagrant-goodhosts
not specify --clean
? Because goodhosts only cleans when the --clean
parameter is passed
from cli.
I'm becoming a pro at posting bugs to the wrong repo. Please move this issue elsewhere if you deem it appropriate.
Unless you meant make
vagrant-goodhosts
not specify--clean
?
Yes, this. As I understand it, doing so isn't something I can control with a config file.
from cli.
You posted in the right repo, but that particular request was for a different piece of software. IIRC @Mte90 has already fixed and merged a PR that makes it configurable and off by default
from cli.
As for this feature, I think these semantics make sense if the CLI is used in conjunction with a --namespace=""
parameter.
When adding a host:
- if the host already exists
- if it exists on a line without the namespace comment on the end
- error message + bad error code
- if it exists on a line with the namespace comment
- remove from file and add on a new line if the IP is different with namespace comment
- do nothing if the IP is the same
- if it exists on a line without the namespace comment on the end
- if it does not exist
- add on a new line with namespace comment
When removing a host:
- if it exists on a line without the namespace comment on the end
- error message + bad error code
- if it exists on a line with the namespace comment
- remove from file
Additionally, the namespace parameter would allow rival namespaces, as well as the ability for us to do things like:
goodhosts remove cnmd.test --namespace="MAMP PRO - Do NOT remove this entry!"
from cli.
all code for doing this should be in the cli, the hostsfile package should just be to parse a hosts file to types. this is logic around what to do with the hostsfile after that is done so this code should be here in this repo, can try doing a first round of this have a line type that uses hostsfile.Line and includes a bool which is we check if we manage the line or not.
This seems sensible
easiest thing is probably a string to match in comment per line like MAMP does, for example as long as it contains goodhosts in the comment we assume it was meant for our cli, just need a something simple like strings.Contains("goodhosts", comment). e.g. we'd manage all of these lines
I think we should allow the namespace to be configurable from the CLI parameter for maximum flexibility, then search for # namespace \n
or equivalent
from cli.
any updates for this @luthermonson?
from cli.
oh thanks for the ping. this fell off my radar. adding it to my task list and ill try and get to it this week
from cli.
@theMikeD latest goodhosts vagrant plugin removed the clean operation a few months ago
from cli.
@luthermonson just a ping again :-D
from cli.
oi vey
from cli.
and it is time for another ping @luthermonson :-D
from cli.
missed this ping... sorry. im bad at getting this feature done.
from cli.
it's me again :-D
I don't know Go otherwise I will try to implement it.
from cli.
is this still an issue with the new release? I saw test cases with MAMP examples were added to the hostsfile repo prior to 1.1.1 release
from cli.
it's not fixed yet, i grabbed the mamp hosts file to try and test it eventually as i started keeping default hosts files to write more tests against
from cli.
Related Issues (19)
- Create Backup Cmd
- Goodhosts don't remove duplicates HOT 10
- Goodhosts issues on OSX HOT 9
- Add a version subcommand or parameter HOT 1
- Goodhosts check requires a writable hosts file HOT 2
- Create Restore Cmd
- clean and check shortened subcommands are the same HOT 1
- More clean options HOT 3
- readme not updated with 1.0.6-1.0.7 HOT 2
- False assumption: IPs appear in a single position HOT 3
- goodhosts stalls when the /etc/hosts file has too many entries HOT 3
- Install cli with brew? HOT 1
- Breaks Windows hosts file line length rules HOT 3
- Windows maximum aliases per line HOT 3
- Crosspost: https://github.com/goodhosts/hostsfile/issues/39 HOT 1
- Q: Maintenance HOT 16
- Bug: Comment detection on host line is missing HOT 3
- Fix BOM HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli.