Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit dd43363

Browse files
committed
Initial Commmit
0 parents  commit dd43363

File tree

3 files changed

+173
-0
lines changed

3 files changed

+173
-0
lines changed

.gitignore

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
# parcel-bundler cache (https://parceljs.org/)
61+
.cache
62+
63+
# next.js build output
64+
.next
65+
66+
# nuxt.js build output
67+
.nuxt
68+
69+
# vuepress build output
70+
.vuepress/dist
71+
72+
# Serverless directories
73+
.serverless

cli.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env node
2+
const chalk = require('chalk');
3+
const Table = require('cli-table');
4+
const getJSON = require('get-json')
5+
const opn = require('opn');
6+
const ora = require('ora')
7+
8+
let cmd = process.argv[2];
9+
10+
11+
if (cmd == "-h" || cmd == "--help") {
12+
ShowHelp();
13+
}
14+
else if (cmd == "-l" || cmd == "--launch") {
15+
opn("www.gitcheats.com?c=" + process.argv[3])
16+
}
17+
else if (cmd) {
18+
GetCommand(process.argv[2])
19+
}
20+
else {
21+
opn("www.gitcheats.com")
22+
}
23+
24+
function ShowHelp() {
25+
console.log("");
26+
console.log("A Terminal App For Reaching Gitcheats.com Easily");
27+
console.log("");
28+
console.log("Commands:");
29+
console.log("gitcheats " + chalk.blue("[command]") + " Get command cheats right into your terminal");
30+
console.log("gitcheats " + chalk.green("-l --launch") + chalk.blue(" [command]") + " Open gitcheats in new browser with your git command");
31+
console.log("gitcheats " + chalk.green("-h --help") + " Display this help");
32+
}
33+
34+
function GetCommand(cmd) {
35+
console.log("\n");
36+
const spinner = ora().start();
37+
spinner.color = 'blue';
38+
spinner.text = chalk.blue("Fetching '" + chalk.green(cmd) + "' from gitcheats.com");
39+
40+
getJSON('https://raw.githubusercontent.com/excalith/Git-Cheats/master/assets/commands.json', function (error, json) {
41+
let data = json.commands[cmd];
42+
console.log("\n\n");
43+
44+
if (data == null) {
45+
console.log("Command " + chalk.red(cmd) + " not found in gitcheats.com");
46+
console.log(chalk.gray("Please consider contributing " + "https://github.com/excalith/Git-Cheats"))
47+
}
48+
else {
49+
var table = new Table({
50+
head: [chalk.green.bold('Option'), chalk.green.bold('Description')],
51+
colWidths: [60, 220],
52+
chars: {
53+
'top': '═', 'top-mid': '╤', 'top-left': '╔', 'top-right': '╗',
54+
'bottom': '═', 'bottom-mid': '╧', 'bottom-left': '╚',
55+
'bottom-right': '╝', 'left': '║', 'left-mid': '╟', 'mid': '─',
56+
'mid-mid': '┼', 'right': '║', 'right-mid': '╢', 'middle': '│'
57+
}
58+
});
59+
60+
table.push(
61+
[cmd, data.desc.en]
62+
);
63+
64+
data.options.forEach(element => {
65+
table.push(
66+
[element.code, element.desc.en]
67+
);
68+
});
69+
70+
console.log(table.toString());
71+
}
72+
73+
spinner.stop();
74+
})
75+
}

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "git-cheats-cli",
3+
"version": "1.0.0",
4+
"description": "A Companion For Gitcheats",
5+
"main": "cli.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "Can Cellek",
10+
"license": "MIT",
11+
"dependencies": {
12+
"chalk": "^2.4.1",
13+
"cli-table": "^0.3.1",
14+
"get-json": "^1.0.0",
15+
"opn": "^5.3.0",
16+
"ora": "^2.1.0"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "https://github.com/excalith/Git-Cheats-Cli.git"
21+
},
22+
"bin": {
23+
"gitcheats": "./cli.js"
24+
}
25+
}

0 commit comments

Comments
 (0)