bench icon indicating copy to clipboard operation
bench copied to clipboard

Provide flag to `add-to-hosts` while creating a new site

Open NagariaHussain opened this issue 2 years ago • 2 comments

Issue: Feature Request

Adding the newly created site is the first thing most of us do while developing on our local machines. Currently, we run a separate command after the site has been created (and sometimes we forget, only to know the page does not open in browser).

We can add a flag like so:

bench new-site cool.mysite.local --add-to-hosts

NagariaHussain avatar Oct 12 '22 00:10 NagariaHussain

Create test sites with following pattern and you don't need to add to them to hosts.

testsite.localhost

ankush avatar Oct 12 '22 03:10 ankush

Create test sites with following pattern and you don't need to add to them to hosts.

testsite.localhost

So, the .localhost extension is automatically routed to local host? Cool!

NagariaHussain avatar Oct 12 '22 06:10 NagariaHussain

So, the .localhost extension is automatically routed to local host? Cool!

Not really. localhost is added to /etc/hosts by default. Your machine's hostname is there too mostly. So site.host also work.

λ cat /etc/hosts
127.0.0.1	localhost  # <--- IPv4
::1		localhost  # <--- IPv6

ankush avatar Nov 01 '22 18:11 ankush

This command is in frappe btw

https://github.com/frappe/frappe/blob/fec24632a9aefdef014be7666af805646f1ce6e8/frappe/commands/site.py#L633-L640

ankush avatar Nov 01 '22 18:11 ankush