New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bang

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bang - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

docs/cli.html

110

lib/bang.js
(function() {
var Bang, Command, exec, fs, path;
var __slice = Array.prototype.slice;
var Bang, fs, pad, path;
Command = require("commander").Command;
fs = require("fs");

@@ -11,47 +8,14 @@

exec = require("child_process").exec;
module.exports = Bang = (function() {
function Bang() {
this.data = this.getData();
this.loadData();
}
Bang.prototype.start = function(args) {
var key, program, value, _ref;
program = new Command;
program.version("0.1.2").usage("[options] [key] [value]").option("-d, --delete", "delete the specified key").option("-h, --help", "get help").parse(args);
_ref = program.args, key = _ref[0], value = _ref[1];
if (program.help) {
return this.log(program.helpInformation());
} else if (key && program["delete"]) {
return this["delete"](key);
} else if (key && value) {
return this.set(key, value);
} else if (key) {
return this.get(key);
} else if (Object.keys(this.data).length === 0) {
return this.log(program.helpInformation());
} else {
return this.list();
}
Bang.prototype.loadData = function() {
var dataPath;
dataPath = process.env.HOME + "/.bang";
return this.data = path.existsSync(dataPath) ? JSON.parse(fs.readFileSync(dataPath)) : {};
};
Bang.prototype.dataPath = process.env.HOME + "/.bang";
Bang.prototype.getData = function() {
if (this.data) return this.data;
if (path.existsSync(this.dataPath)) {
return JSON.parse(fs.readFileSync(this.dataPath));
} else {
return {};
}
};
Bang.prototype.log = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return console.log.apply(console, args);
};
Bang.prototype.save = function() {

@@ -62,8 +26,3 @@ return fs.writeFileSync(this.dataPath, JSON.stringify(this.data));

Bang.prototype.get = function(key) {
var value;
value = this.data[key];
if (!value) return;
this.copy(value);
this.log(value);
return value;
return this.data[key];
};

@@ -73,4 +32,3 @@

this.data[key] = value;
this.save();
return this;
return this.save();
};

@@ -80,8 +38,8 @@

delete this.data[key];
this.save();
return this;
return this.save();
};
Bang.prototype.list = function() {
var amount, key;
var amount, key, lines;
lines = [];
amount = 0;

@@ -92,38 +50,7 @@ for (key in this.data) {

for (key in this.data) {
this.log("" + (this.pad(key, amount)) + key + ": " + this.data[key]);
lines.push("" + (pad(key, amount)) + key + ": " + (this.get(key)));
}
return this;
return lines.join("\n");
};
Bang.prototype.copy = function(value) {
var copyCommand;
copyCommand = (function() {
switch (process.platform) {
case "darwin":
return "pbcopy";
case "win32":
return "clip";
default:
return "xclip -selection clipboard";
}
})();
if (process.platform === "win32") {
exec("echo " + (value.replace(/\'/g, "\\'")) + " | " + copyCommand);
} else {
exec("printf '" + (value.replace(/\'/g, "\\'")) + "' | " + copyCommand);
}
return this;
};
Bang.prototype.pad = function(item, amount) {
var i, out;
out = "";
i = amount - item.length;
while (i > 0) {
out += " ";
i--;
}
return out;
};
return Bang;

@@ -133,2 +60,13 @@

pad = function(item, amount) {
var i, out;
out = "";
i = amount - item.length;
while (i > 0) {
out += " ";
i--;
}
return out;
};
}).call(this);

@@ -5,3 +5,3 @@ {

"description": "Text snippets on the command line.",
"version": "0.1.2",
"version": "0.2.0",
"homepage": "https://github.com/jimmycuadra/bang",

@@ -12,2 +12,3 @@ "repository": {

},
"main": "./lib/bang",
"bin": {

@@ -14,0 +15,0 @@ "bang": "./bin/bang"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc