Skip to content

Commit

Permalink
qrcodemodel: Use qrcodeterminal to render qrcode
Browse files Browse the repository at this point in the history
It's a more specialized library with more update and simpler
implementation since it only targets terminals.

It also support sixel rendering when supported.

Golden files doesn't seem to handle the rendering of the big qrcodes
properly, but they're definitely written in the right way
  • Loading branch information
3v1n0 committed Jun 25, 2024
1 parent 4c3532b commit 25486ce
Show file tree
Hide file tree
Showing 8 changed files with 612 additions and 597 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ require (
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/godbus/dbus/v5 v5.1.0
github.com/google/uuid v1.6.0
github.com/mdp/qrterminal/v3 v3.2.0
github.com/msteinert/pam/v2 v2.0.0
github.com/muesli/termenv v0.15.2
github.com/sirupsen/logrus v1.9.3
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
Expand Down Expand Up @@ -68,6 +68,7 @@ require (
golang.org/x/sync v0.7.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
rsc.io/qr v0.2.0 // indirect
)

// FIXME: Use released version once we have one!
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+Ei
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mdp/qrterminal/v3 v3.2.0 h1:qteQMXO3oyTK4IHwj2mWsKYYRBOp1Pj2WRYFYYNTCdk=
github.com/mdp/qrterminal/v3 v3.2.0/go.mod h1:XGGuua4Lefrl7TLEsSONiD+UEjQXJZ4mPzF+gWYIJkk=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
Expand Down Expand Up @@ -88,8 +90,6 @@ github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f h1:MvTmaQdww/z0Q4wr
github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
Expand Down Expand Up @@ -154,3 +154,5 @@ gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY=
rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs=
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,19 @@ Scan the qrcode or enter the code in the login page

█████████████████████████████████
█████████████████████████████████
████ ▄▄▄▄▄ █ ▀▀█▄██ █ ▄▄▄▄▄ ████
████ █ █ █▀▄██ ▄▄▄██ █ █ ████
████ █▄▄▄█ █▄ █ ▄ ▄▄█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀▄▀▄▀ ▀▄█▄▄▄▄▄▄▄████
████▄█ ▄█ ▄ ▀█▄▀▀▄▄█ █▄▀█▄█████
█████▀█▀▄ ▄ ▄▀█▀▀▀ ▀█▄▀▄▄▀▀██████
████▄ █▀█▄▄▄██ █▀█▀█▄ █▄▄ ████
████▀▄ ▀▄▄█ ▄▄█ ▀▄▀▀ ▀▀ █▄▄▀████
███████▄▄█▄█ ▀▄▀▀█▀ ▄▄▄ ▄ ▄ ████
████ ▄▄▄▄▄ █ █▄ ██▀ █▄█ █▄ ████
████ █ █ █▀▄ ▀▀▄ ▄ ▀▀▀████
████ █▄▄▄█ █▄█▄▄▄▄█ █ █ █ ▄█████
████▄▄▄▄▄▄▄█▄█▄█▄█▄████▄▄▄▄▄▄████
████ ▄▄▄▄▄ █▀█ ▀█ ▀█ ▄▄▄▄▄ ████
████ █ █ ██▄█▀█▀█▄██ █ █ ████
████ █▄▄▄█ █▄ █ ▀▄ ▀█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█▄█▄▀▄█▄█▄█▄▄▄▄▄▄▄████
████ ▀ █▄█▄█▀█▄█▄▀██ ▀▀█▄██▄▀████
████▄▀██▀█▄ ▄█ ▄ ▀ █ ▀ ▄▄█▄ ▄████
████▄▄█▄ ▀ ▄ ██ ▄▄▄ ▄█ █▄ ████
████▄▀▀ ▀ ▄ ▀▄▄▀█▄█▀▀▄▄▄▀█▄ ▄████
████▄██▄█▄▄█ ▄▄▀ ▀██ ▄▄▄ █▀▀████
████ ▄▄▄▄▄ ███▄▄ ▀ ▄ █▄█ ████
████ █ █ ███ ▀▄▄▄ ▀█▄████
████ █▄▄▄█ █▄▀▀▀█▄█▄ █▀█ ▀█▀▄████
████▄▄▄▄▄▄▄█▄▄██▄██▄▄██▄███▄▄████
█████████████████████████████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
1337
Expand Down Expand Up @@ -243,19 +243,19 @@ Scan the qrcode or enter the code in the login page

█████████████████████████████████
█████████████████████████████████
████ ▄▄▄▄▄ █ ▀▀█▄██ █ ▄▄▄▄▄ ████
████ █ █ █▀▄██ ▄▄▄██ █ █ ████
████ █▄▄▄█ █▄ █ ▄ ▄▄█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀▄▀▄▀ ▀▄█▄▄▄▄▄▄▄████
████▄█ ▄█ ▄ ▀█▄▀▀▄▄█ █▄▀█▄█████
█████▀█▀▄ ▄ ▄▀█▀▀▀ ▀█▄▀▄▄▀▀██████
████▄ █▀█▄▄▄██ █▀█▀█▄ █▄▄ ████
████▀▄ ▀▄▄█ ▄▄█ ▀▄▀▀ ▀▀ █▄▄▀████
███████▄▄█▄█ ▀▄▀▀█▀ ▄▄▄ ▄ ▄ ████
████ ▄▄▄▄▄ █ █▄ ██▀ █▄█ █▄ ████
████ █ █ █▀▄ ▀▀▄ ▄ ▀▀▀████
████ █▄▄▄█ █▄█▄▄▄▄█ █ █ █ ▄█████
████▄▄▄▄▄▄▄█▄█▄█▄█▄████▄▄▄▄▄▄████
████ ▄▄▄▄▄ █▀█ ▀█ ▀█ ▄▄▄▄▄ ████
████ █ █ ██▄█▀█▀█▄██ █ █ ████
████ █▄▄▄█ █▄ █ ▀▄ ▀█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█▄█▄▀▄█▄█▄█▄▄▄▄▄▄▄████
████ ▀ █▄█▄█▀█▄█▄▀██ ▀▀█▄██▄▀████
████▄▀██▀█▄ ▄█ ▄ ▀ █ ▀ ▄▄█▄ ▄████
████▄▄█▄ ▀ ▄ ██ ▄▄▄ ▄█ █▄ ████
████▄▀▀ ▀ ▄ ▀▄▄▀█▄█▀▀▄▄▄▀█▄ ▄████
████▄██▄█▄▄█ ▄▄▀ ▀██ ▄▄▄ █▀▀████
████ ▄▄▄▄▄ ███▄▄ ▀ ▄ █▄█ ████
████ █ █ ███ ▀▄▄▄ ▀█▄████
████ █▄▄▄█ █▄▀▀▀█▄█▄ █▀█ ▀█▀▄████
████▄▄▄▄▄▄▄█▄▄██▄██▄▄██▄███▄▄████
█████████████████████████████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
1337
Expand Down Expand Up @@ -283,19 +283,19 @@ Scan the qrcode or enter the code in the login page

█████████████████████████████████
█████████████████████████████████
████ ▄▄▄▄▄ █ ▀▀█▄██ █ ▄▄▄▄▄ ████
████ █ █ █▀▄██ ▄▄▄██ █ █ ████
████ █▄▄▄█ █▄ █ ▄ ▄▄█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀▄▀▄▀ ▀▄█▄▄▄▄▄▄▄████
████▄█ ▄█ ▄ ▀█▄▀▀▄▄█ █▄▀█▄█████
█████▀█▀▄ ▄ ▄▀█▀▀▀ ▀█▄▀▄▄▀▀██████
████▄ █▀█▄▄▄██ █▀█▀█▄ █▄▄ ████
████▀▄ ▀▄▄█ ▄▄█ ▀▄▀▀ ▀▀ █▄▄▀████
███████▄▄█▄█ ▀▄▀▀█▀ ▄▄▄ ▄ ▄ ████
████ ▄▄▄▄▄ █ █▄ ██▀ █▄█ █▄ ████
████ █ █ █▀▄ ▀▀▄ ▄ ▀▀▀████
████ █▄▄▄█ █▄█▄▄▄▄█ █ █ █ ▄█████
████▄▄▄▄▄▄▄█▄█▄█▄█▄████▄▄▄▄▄▄████
████ ▄▄▄▄▄ █▀█ ▀█ ▀█ ▄▄▄▄▄ ████
████ █ █ ██▄█▀█▀█▄██ █ █ ████
████ █▄▄▄█ █▄ █ ▀▄ ▀█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█▄█▄▀▄█▄█▄█▄▄▄▄▄▄▄████
████ ▀ █▄█▄█▀█▄█▄▀██ ▀▀█▄██▄▀████
████▄▀██▀█▄ ▄█ ▄ ▀ █ ▀ ▄▄█▄ ▄████
████▄▄█▄ ▀ ▄ ██ ▄▄▄ ▄█ █▄ ████
████▄▀▀ ▀ ▄ ▀▄▄▀█▄█▀▀▄▄▄▀█▄ ▄████
████▄██▄█▄▄█ ▄▄▀ ▀██ ▄▄▄ █▀▀████
████ ▄▄▄▄▄ ███▄▄ ▀ ▄ █▄█ ████
████ █ █ ███ ▀▄▄▄ ▀█▄████
████ █▄▄▄█ █▄▀▀▀█▄█▄ █▀█ ▀█▀▄████
████▄▄▄▄▄▄▄█▄▄██▄██▄▄██▄███▄▄████
█████████████████████████████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
1337
Expand Down Expand Up @@ -323,19 +323,19 @@ Scan the qrcode or enter the code in the login page

█████████████████████████████████
█████████████████████████████████
████ ▄▄▄▄▄ █ ▀▀█▄██ █ ▄▄▄▄▄ ████
████ █ █ █▀▄██ ▄▄▄██ █ █ ████
████ █▄▄▄█ █▄ █ ▄ ▄▄█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀▄▀▄▀ ▀▄█▄▄▄▄▄▄▄████
████▄█ ▄█ ▄ ▀█▄▀▀▄▄█ █▄▀█▄█████
█████▀█▀▄ ▄ ▄▀█▀▀▀ ▀█▄▀▄▄▀▀██████
████▄ █▀█▄▄▄██ █▀█▀█▄ █▄▄ ████
████▀▄ ▀▄▄█ ▄▄█ ▀▄▀▀ ▀▀ █▄▄▀████
███████▄▄█▄█ ▀▄▀▀█▀ ▄▄▄ ▄ ▄ ████
████ ▄▄▄▄▄ █ █▄ ██▀ █▄█ █▄ ████
████ █ █ █▀▄ ▀▀▄ ▄ ▀▀▀████
████ █▄▄▄█ █▄█▄▄▄▄█ █ █ █ ▄█████
████▄▄▄▄▄▄▄█▄█▄█▄█▄████▄▄▄▄▄▄████
████ ▄▄▄▄▄ █▀█ ▀█ ▀█ ▄▄▄▄▄ ████
████ █ █ ██▄█▀█▀█▄██ █ █ ████
████ █▄▄▄█ █▄ █ ▀▄ ▀█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█▄█▄▀▄█▄█▄█▄▄▄▄▄▄▄████
████ ▀ █▄█▄█▀█▄█▄▀██ ▀▀█▄██▄▀████
████▄▀██▀█▄ ▄█ ▄ ▀ █ ▀ ▄▄█▄ ▄████
████▄▄█▄ ▀ ▄ ██ ▄▄▄ ▄█ █▄ ████
████▄▀▀ ▀ ▄ ▀▄▄▀█▄█▀▀▄▄▄▀█▄ ▄████
████▄██▄█▄▄█ ▄▄▀ ▀██ ▄▄▄ █▀▀████
████ ▄▄▄▄▄ ███▄▄ ▀ ▄ █▄█ ████
████ █ █ ███ ▀▄▄▄ ▀█▄████
████ █▄▄▄█ █▄▀▀▀█▄█▄ █▀█ ▀█▀▄████
████▄▄▄▄▄▄▄█▄▄██▄██▄▄██▄███▄▄████
█████████████████████████████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
1337
Expand Down Expand Up @@ -363,19 +363,19 @@ Scan the qrcode or enter the code in the login page

█████████████████████████████████
█████████████████████████████████
████ ▄▄▄▄▄ █ ▀▀█▄██ █ ▄▄▄▄▄ ████
████ █ █ █▀▄██ ▄▄▄██ █ █ ████
████ █▄▄▄█ █▄ █ ▄ ▄▄█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀▄▀▄▀ ▀▄█▄▄▄▄▄▄▄████
████▄█ ▄█ ▄ ▀█▄▀▀▄▄█ █▄▀█▄█████
█████▀█▀▄ ▄ ▄▀█▀▀▀ ▀█▄▀▄▄▀▀██████
████▄ █▀█▄▄▄██ █▀█▀█▄ █▄▄ ████
████▀▄ ▀▄▄█ ▄▄█ ▀▄▀▀ ▀▀ █▄▄▀████
███████▄▄█▄█ ▀▄▀▀█▀ ▄▄▄ ▄ ▄ ████
████ ▄▄▄▄▄ █ █▄ ██▀ █▄█ █▄ ████
████ █ █ █▀▄ ▀▀▄ ▄ ▀▀▀████
████ █▄▄▄█ █▄█▄▄▄▄█ █ █ █ ▄█████
████▄▄▄▄▄▄▄█▄█▄█▄█▄████▄▄▄▄▄▄████
████ ▄▄▄▄▄ █▀█ ▀█ ▀█ ▄▄▄▄▄ ████
████ █ █ ██▄█▀█▀█▄██ █ █ ████
████ █▄▄▄█ █▄ █ ▀▄ ▀█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█▄█▄▀▄█▄█▄█▄▄▄▄▄▄▄████
████ ▀ █▄█▄█▀█▄█▄▀██ ▀▀█▄██▄▀████
████▄▀██▀█▄ ▄█ ▄ ▀ █ ▀ ▄▄█▄ ▄████
████▄▄█▄ ▀ ▄ ██ ▄▄▄ ▄█ █▄ ████
████▄▀▀ ▀ ▄ ▀▄▄▀█▄█▀▀▄▄▄▀█▄ ▄████
████▄██▄█▄▄█ ▄▄▀ ▀██ ▄▄▄ █▀▀████
████ ▄▄▄▄▄ ███▄▄ ▀ ▄ █▄█ ████
████ █ █ ███ ▀▄▄▄ ▀█▄████
████ █▄▄▄█ █▄▀▀▀█▄█▄ █▀█ ▀█▀▄████
████▄▄▄▄▄▄▄█▄▄██▄██▄▄██▄███▄▄████
█████████████████████████████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
1337
Expand Down
Loading

0 comments on commit 25486ce

Please sign in to comment.