Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
add domains command
Browse files Browse the repository at this point in the history
  • Loading branch information
wdhdev authored Mar 7, 2023
1 parent 8bfcd04 commit 309dccd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/functions/domains.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const Conf = require("conf");
const fetch = require("node-fetch");

const account = new Conf();

module.exports = async function domains() {
if(!account.has("username")) {
console.log("You are not logged in!");
console.log("To log in, run the command: `domains login`");
return;
}

console.log(`Username: ${account.get("username")}`);
console.log(`Email: ${account.get("email")}\n`);

const email = account.get("email");

const res = await fetch(`https://api.freesubdomains.org/lookup/user?email=${email}`);

if(res.status === 500) return console.log("An error occurred, please try again later.");
if(res.status === 404) return console.log("You do not own any domains.");

const domains = res.subdomains;

return console.log(`Your Domains:\n${domains.join("\n")}`);
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const { clear, debug } = flags;

input.includes("account") && functions.account();
input.includes("check") && functions.check();
input.includes("domains") && functions.domains();
input.includes("help") && cli.showHelp(0);
input.includes("login") && functions.login();
input.includes("logout") && functions.logout();
Expand Down
1 change: 1 addition & 0 deletions src/util/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const flags = {
const commands = {
account: { desc: "Get information about your account." },
check: { desc: "Check if a subdomain is available." },
domains: { desc: "Get a list of all your domains." },
login: { desc: "Login to your GitHub account." },
logout: { desc: "Logout of your GitHub account." },
register: { desc: "Register a subdomain." },
Expand Down
1 change: 1 addition & 0 deletions src/util/functions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
"account": require("../functions/account"),
"check": require("../functions/check"),
"domains": require("../functions/domains"),
"login": require("../functions/login"),
"logout": require("../functions/logout"),
"register": require("../functions/register"),
Expand Down

0 comments on commit 309dccd

Please sign in to comment.