4 个版本
| 0.2.2 | 2023年10月21日 | 
|---|---|
| 0.2.1 | 2023年10月21日 | 
| 0.2.0 | 2023年10月21日 | 
| 0.1.0 | 2023年10月20日 | 
#2601 在 命令行工具
56KB
187 行
csv2qr
背景
我的朋友告诉我他们需要生成一些二维码。自然地,我用 Rust 写了一个命令行工具。
先决条件
使用 rustup 安装 cargo。然后只需使用 csv2qr 通过 cargo install csv2qr 安装 rustup 应该已正确设置你的 PATH,但在 Windows 上你可能需要重新启动或类似操作。我不知道,我不使用 Windows。
用法
用法应该是相当直观的,csv2qr 包含命令行帮助。您需要指定的唯一参数是 CSV 文件,其中第一列是“标题”,第二列是要编码到二维码中的值。这里有一个示例文件 这里。
$ csv2qr -h
csv2qr 0.2.0
A simple command line tool for generating QR codes from a CSV file.
USAGE:
    csv2qr [OPTIONS] <CSV_PATH> [OUTPUT_PATH]
ARGS:
    <CSV_PATH>       CSV file to parse
    <OUTPUT_PATH>    Output directory [default: .]
OPTIONS:
    -d, --debug                Turn on debug output
        --ecc <ECC>            ECC level (low, medium, quartile, or high) [default: medium]
    -h, --help                 Print help information
    -n, --no-pdf               Do not generate the final PDF document, only the intermediate PNG.
                               This will enable save-intermediate automatically
    -s, --save-intermediate    Do not delete the intermediate PNG of the QR code
    -V, --version              Print version information
csv2qr 将为 CSV 中的每一行创建一个带标题/标签的二维码 PDF。例如,
$ mkdir /tmp/csv2qr
$ csv2qr example/example.csv /tmp/csv2qr
$ ls -l /tmp/csv2qr
total 7856
-rw-rw-r-- 1 myuser myuser 2008838 Oct 20 17:35 Hack_the_planet.pdf
-rw-rw-r-- 1 myuser myuser 2009061 Oct 20 17:35 I_am_not_a_martyr_I%27m_a_problem.pdf
-rw-rw-r-- 1 myuser myuser 2008905 Oct 20 17:35 Prodigy_-_Mind_Fields.pdf
-rw-rw-r-- 1 myuser myuser 2008892 Oct 20 17:35 This_is_what_I_do.pdf
特别感谢
这只是将其他 Rust 包粘合在一起的简单代码。真正的魔法发生在 genpdf 和 qrcode-generator 包中。测试是由 bardecoder 和 image 包实现的。我还包括了来自 Calling Code 字体 的 text-to-png 包的源代码。
据我所知,它全部都是纯 Rust。我在 Kubuntu 22.04 上使用 Rust 1.66.1 和 Windows 10 上使用 Rust 1.73.0 进行了测试。它可能在其他平台上也能运行。
依赖项
~36–50MB
~417K SLoC