Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add input from the clipboard #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ If you want to display small output, provide `opts` with `small`:
$ qrcode-terminal --help
$ qrcode-terminal 'http://github.com'
$ echo 'http://github.com' | qrcode-terminal
$ qrcode-terminal # qr code generated from clipboard

# Support

Expand Down
6 changes: 4 additions & 2 deletions bin/qrcode-terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ var name = process.argv[1].replace(/^.*[\\\/]/, '').replace('.js', '');
*/

if (process.stdin.isTTY) {
// called with input as argument, e.g.:
// called with input as argument or from clipboard, e.g.:
// ./qrcode-terminal.js "INPUT"

var input = process.argv[2];
// If not passed argument, then read from clipboard
var input = process.argv[2] ? process.argv[2] : require('clipboardy').readSync();

handleInput(input);
} else {
// called with piped input, e.g.:
Expand Down
45 changes: 29 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
{
"name": "qrcode-terminal",
"keywords": ["ansi", "ascii", "qrcode", "console"],
"version" : "0.12.0",
"description" : "QRCodes, in the terminal",
"keywords": [
"ansi",
"ascii",
"qrcode",
"console"
],
"version": "0.12.0",
"description": "QRCodes, in the terminal",
"homepage": "https://github.com/gtanner/qrcode-terminal",
"repository": {
"type": "git",
"url": "https://github.com/gtanner/qrcode-terminal"
},
"contributors": [{
"name": "Gord Tanner",
"email": "[email protected]",
"url": "http://github.com/gtanner"
}, {
"name": "Michael Brooks",
"email": "[email protected]",
"url": "http://github.com/mwbrooks"
}],
"licenses": [{
"type": "Apache 2.0"
}],
"contributors": [
{
"name": "Gord Tanner",
"email": "[email protected]",
"url": "http://github.com/gtanner"
},
{
"name": "Michael Brooks",
"email": "[email protected]",
"url": "http://github.com/mwbrooks"
}
],
"licenses": [
{
"type": "Apache 2.0"
}
],
"main": "./lib/main",
"bin": {
"qrcode-terminal": "./bin/qrcode-terminal.js"
"qrcode-terminal": "./bin/qrcode-terminal.js"
},
"preferGlobal": false,
"devDependencies": {
Expand All @@ -33,5 +43,8 @@
},
"scripts": {
"test": "./node_modules/jshint/bin/jshint lib vendor && node example/basic.js && ./node_modules/mocha/bin/mocha -R nyan"
},
"dependencies": {
"clipboardy": "^1.2.3"
}
}