GithubHelp home page GithubHelp logo

namecheap-cli's Introduction

Namecheap CLI

Introduction

Once upon a time, I naively thought to myself:

Wouldn't it be nice if I could modify my DNS records from the CLI with a quick command, rather than needing to open the browser, log in, navigate to what I needed, make the changes only to then close all of those things again?

To some extent - I agree with that old, more naive version of me. Only with the added twist of knowing that I'd be insane to try such a thing with the horrible API provided by Namecheap, and what appears to be a lack of intent to do anything about it. People have been asking for fairly simple improvements for many moons. It's "with the product team". Who knows, maybe they'll improve it soon. Will I have finished migrating to a new DNS by then? Probably.

Installation

Install using npm i -g dns-namecheap-cli.

Configuration

The configuration is stored in a file called .namecheap-cli in the users home directory. The home directory is found using require('os').homedir(), so it should be fairly reliable.

A configuration file is created when you try to use a command that requires it. You can update the config manually by editing the json, or use the config commands.

# namecheap-cli config set username J4Wx
# namecheap-cli config set apiKey someApiKeyStringHere

Should do the trick!

Commands!

There are currently only a handful of commands. It's unlikely I'll add any more, but I'm open to it. And PRs are welcome.

Config

Config has two subcommands; get and set.

config get

You can check a config file entry using:

# namecheap-cli config:get <field>

For example:

# namecheap-cli config:get username
The current config setting for username is J4Wx

config set

You can update a config file entry using:

# namecheap-cli config:set <field> <value>

For example:

# namecheap-cli config:set username J4Wx

Domains

You can interact with your domains, well... list them ¯\(ツ)/¯.

domains:list

This command will return a list of the domains on your account. Each page will return 20 results.

# namecheap-cli domains:list <page = 1>

Hosts

You can interact with your domains hosts! This is where it gets useful. At least a little bit.

hosts:list

This command will return a list of the hosts for a domain.

# namecheap-cli domains:list <domain>

For example:

# namecheap-cli domains:list github.com

hosts:set

This command will update the specified host with the params you provide. Technically it will actually update all of your hosts thanks to the fact the setHosts method deletes and adds every single host. A list of your current hosts is retrieved (and updated if required) and sent back. So your hosts shouldn't change.

Don't ask why.

# namecheap-cli hosts:set <domain> <hostname> <type> <address> <ttl = 1800>

So to add add/update an entry at demo.github.com to point to 1.1.1.1 with type A and a TTL of 30000, you would execute:

# namecheap-cli hosts:set github.com demo a 1.1.1.1 30000

namecheap-cli's People

Contributors

j4wx avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.