From 6113acfc50e5344a71df4bc1e9edfaebfa10a2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Ramadas?= Date: Wed, 4 Apr 2018 22:33:47 +0100 Subject: [PATCH 1/2] Add input from clipboard --- bin/qrcode-terminal.js | 6 ++++-- package.json | 45 +++++++++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/bin/qrcode-terminal.js b/bin/qrcode-terminal.js index 6476287..e276d8a 100755 --- a/bin/qrcode-terminal.js +++ b/bin/qrcode-terminal.js @@ -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.: diff --git a/package.json b/package.json index 9a6b9e7..6a35a42 100644 --- a/package.json +++ b/package.json @@ -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": "gtanner@gmail.com", - "url": "http://github.com/gtanner" - }, { - "name": "Michael Brooks", - "email": "mikeywbrooks@gmail.com", - "url": "http://github.com/mwbrooks" - }], - "licenses": [{ - "type": "Apache 2.0" - }], + "contributors": [ + { + "name": "Gord Tanner", + "email": "gtanner@gmail.com", + "url": "http://github.com/gtanner" + }, + { + "name": "Michael Brooks", + "email": "mikeywbrooks@gmail.com", + "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": { @@ -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" } } From 7e69a10c0af47e3a09bbbae4bf4869b000bddb8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Ramadas?= Date: Wed, 4 Apr 2018 22:34:54 +0100 Subject: [PATCH 2/2] Update README.md (include usage of clipboard input) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f5c830f..62b9271 100644 --- a/README.md +++ b/README.md @@ -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