├── .gitignore ├── LICENSE ├── README.md ├── images └── qrcode-cli.png ├── qrcode_cli ├── __init__.py └── main.py └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | 3 | build/ 4 | dist/ 5 | qrcode_cli.egg-info/ 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Everley1993 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # qrcode-cli 2 | 二维码命令行工具--将二维码输出到终端而不是图片文件 3 | 4 | ## 安装 5 | ```bash 6 | pip install git+git://github.com/Everley1993/qrcode-cli.git 7 | ``` 8 | ## 使用 9 | ```bash 10 | qrcode-cli -d "your data" 11 | ``` 12 | ## 效果 13 | ![qrcode-cli](https://raw.githubusercontent.com/Everley1993/qrcode-cli/master/images/qrcode-cli.png) 14 | -------------------------------------------------------------------------------- /images/qrcode-cli.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColaMint/qrcode-cli/96592670b9847a8449c1b222249ad2e7c5605860/images/qrcode-cli.png -------------------------------------------------------------------------------- /qrcode_cli/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColaMint/qrcode-cli/96592670b9847a8449c1b222249ad2e7c5605860/qrcode_cli/__init__.py -------------------------------------------------------------------------------- /qrcode_cli/main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | import qrcode 4 | from optparse import OptionParser 5 | import sys 6 | 7 | parser = OptionParser() 8 | parser.add_option('-d', '--data', dest='data', help='data to be processed') 9 | 10 | white_block = '\033[0;37;47m ' 11 | black_block = '\033[0;37;40m ' 12 | new_line = '\033[0m\n' 13 | 14 | def main(): 15 | (options, args) = parser.parse_args() 16 | if not options.data: 17 | print 'data must be specified. see %s -h' % sys.argv[0] 18 | else: 19 | qr = qrcode.QRCode(version=5) 20 | qr.add_data(options.data) 21 | qr.make() 22 | output = '' 23 | output += new_line 24 | output += white_block*(qr.modules_count+2) + new_line 25 | for r in range(qr.modules_count): 26 | output += white_block 27 | for c in range(qr.modules_count): 28 | if qr.modules[r][c]: 29 | output += black_block 30 | else: 31 | output += white_block 32 | output += white_block + new_line 33 | output += white_block*(qr.modules_count+2) + new_line 34 | print output 35 | 36 | if __name__ == '__main__': 37 | main() 38 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from setuptools import setup, find_packages 3 | 4 | setup( 5 | name='qrcode_cli', 6 | version='0.1', 7 | url='https://github.com/Everley1993/qrcode-cli', 8 | description='QR Code shell generator', 9 | license='MIT', 10 | author='Everley', 11 | author_email='463785757@qq.com', 12 | platforms=['any'], 13 | packages=find_packages(), 14 | entry_points={ 15 | 'console_scripts': [ 16 | 'qrcode-cli= qrcode_cli.main:main', 17 | ], 18 | }, 19 | install_requires=['Pillow', 'qrcode'], 20 | include_package_data=True, 21 | ) 22 | --------------------------------------------------------------------------------