Skip to main content

switchto

switch between dev and prod environments from command line.

Installation

pip install switchto

How it works

It edits your hosts file locally on Windows, Linux and Mac.

Usage

Add entry

switchto -s my.website.com dev:127.0.0.1 team:192.168.1.100 prod:

This will create 3 entries for your website domain, named "dev", "team" and "prod". An empty string indicates to remove the entry from the hosts file once you run switchto that rule.

Switching from production to dev environment and back

switchto dev

Will add the following entry to your hosts:

127.0.0.1 my.website.com

Once you want to go back to production, you can:

switchto prod

Remove entries

You cannot remove entires from the config file, you can however set the rule to an empty string:

switchto -s my.website.com team:

Note: settings are saved in .s2.json on HOME or HOMEPATH directory.

Listing config

switchto -l

To list everything, or:

switchto -l regex

Which will list all rules matching that regex.

CNAMEs

Currently, switchto works only via hosts, which do not support redirecting domains to other domains, but only by IP address. You can create a rule with a target domain, but it will be resolved once you create the rule, and also you would have to pass "-y" to confirm this:

switchto -y -s my.website.com dev:my.website.local dev

Note the "dev" at the end, which specifies to make the switch instantly, rather than running "switchto dev" afterwards.

Release files for switchto 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for switchto 0.0.3
File Size Uploaded
switchto-0.0.3.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for switchto 0.0.3
File Interpreter ABI Platform
switchto-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / switchto-0.0.3.tar.gz

Download URL switchto-0.0.3.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fbbdd276e083635dff08c083b3dfe4aa24e66c4b47d79e6fba7523a06fa32a5c
BLAKE2b-256 checksum
How to use checksums
8995c2172a6e22d8355232c19f71cc7d05203878a501b844f30001ae04fc42bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.7

Release files / switchto-0.0.3-py3-none-any.whl

Download URL switchto-0.0.3-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fec2f8295c1bb8be4d40351e319235e1e737522d026f7a2fea8bbad9666a1201
BLAKE2b-256 checksum
How to use checksums
3a40b6948e1be5ec15d2167410efdd1317bd96a1c842ed36a5e75b8a81540845
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page