localhosts-cli
v1.0.2
Published
A simple command-line tool for managing Windows hosts file entries with ease.
Readme
localhosts-cli
A simple command-line tool for managing Windows hosts file entries with ease.
Description
localhosts-cli is a Node.js-based command-line tool that simplifies the process of adding and managing entries in your Windows system's hosts file. It provides a user-friendly interface to modify the hosts file without manually editing it, reducing the risk of syntax errors and improving efficiency.
Installation
Install the tool globally using npm:
npm install -g localhosts-cliUsage
The tool provides a simple command interface to add new host entries. You'll need to run your command prompt or terminal as Administrator since modifying the hosts file requires elevated privileges.
Basic command syntax:
localhosts-cli add <ip-address> <hostname>Example:
localhosts-cli add 127.0.0.1 mydev.localThis will add the following entry to your hosts file:
127.0.0.1 mydev.localHow It Works
The tool performs the following operations:
- Validates the provided IP address and hostname format
- Checks for administrator privileges
- Reads the current hosts file (located at
C:\Windows\System32\drivers\etc\hosts) - Adds the new entry while preserving existing content
- Saves the modified file back to the system
The tool ensures that:
- Duplicate entries are not created
- The hosts file format is maintained
- Existing entries remain unchanged
- Proper spacing and formatting are applied
Important Notes
- Windows Only: This tool is specifically designed for Windows operating systems
- Administrator Rights Required: You must run the command prompt as Administrator
- File Location: The hosts file is located at
C:\Windows\System32\drivers\etc\hosts
License
This project is licensed under the MIT License - see the LICENSE file for details.
