Skip to content

Commit

Permalink
add version flag + date format
Browse files Browse the repository at this point in the history
  • Loading branch information
godcrampy committed Apr 24, 2020
1 parent 2e54258 commit 3014672
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
13 changes: 10 additions & 3 deletions dist/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ var node_emoji_1 = __importDefault(require("node-emoji"));
clear_1.default();
console.log(chalk_1.default.rgb(255, 22, 84)(figlet_1.default.textSync("Stalk", {
font: "ANSI Shadow",
})));
}) + chalk_1.default.bold(" v1.0.0")));
if (process_1.default.argv.length !== 3) {
console.log(chalk_1.default.bold("Usage:"));
console.log(chalk_1.default.whiteBright(" stalk [username]"));
return [2 /*return*/];
}
if (["--help", "-h"].includes(process_1.default.argv[2])) {
if (["--help", "-h", "--version", "-v"].includes(process_1.default.argv[2])) {
console.log(chalk_1.default.bold("Usage:"));
console.log(chalk_1.default.whiteBright(" stalk [username]"));
return [2 /*return*/];
Expand All @@ -88,7 +88,7 @@ var node_emoji_1 = __importDefault(require("node-emoji"));
printPair("Location", user.location);
printPair("Works At", user.company);
printPair("Blog", user.blog);
printPair("Joined", user.created_at);
printPair("Joined", beautifyDate(user.created_at));
printPair("Looking for a job?", user.hireable ? "Yes" : "No");
printPair("Repos", user.public_repos.toString());
printPair("Followers", user.followers.toString());
Expand All @@ -102,3 +102,10 @@ function printPair(left, right) {
console.log(chalk_1.default.bold.green(left) + ": " + right);
}
}
function beautifyDate(s) {
return new Date(s).toLocaleDateString([], {
month: "short",
day: "numeric",
year: "numeric"
});
}
14 changes: 11 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type User = {
)(
figlet.textSync("Stalk", {
font: "ANSI Shadow",
})
}) + chalk.bold(" v1.0.0")
)
);
if (process.argv.length !== 3) {
Expand All @@ -43,7 +43,7 @@ type User = {
return;
}

if (["--help", "-h"].includes(process.argv[2])) {
if (["--help", "-h", "--version", "-v"].includes(process.argv[2])) {
console.log(chalk.bold("Usage:"));
console.log(chalk.whiteBright(" stalk [username]"));
return;
Expand Down Expand Up @@ -79,7 +79,7 @@ type User = {
printPair("Location", user.location);
printPair("Works At", user.company);
printPair("Blog", user.blog);
printPair("Joined", user.created_at);
printPair("Joined", beautifyDate(user.created_at));
printPair("Looking for a job?", user.hireable ? "Yes" : "No");
printPair("Repos", user.public_repos.toString());
printPair("Followers", user.followers.toString());
Expand All @@ -91,3 +91,11 @@ function printPair(left: string, right: string) {
console.log(`${chalk.bold.green(left)}: ${right}`);
}
}

function beautifyDate(s: string): string {
return new Date(s).toLocaleDateString([], {
month: "short",
day: "numeric",
year: "numeric",
});
}

0 comments on commit 3014672

Please sign in to comment.