diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..42b750d --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Poetry Lock File +poetry.lock + +# Poetry build files +dist + +# Any image files +*.png +*.jpg diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..1c2fda5 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..d8e9561 --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a5d1095 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..6f3e585 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/qrtool.iml b/.idea/qrtool.iml new file mode 100644 index 0000000..d9e6024 --- /dev/null +++ b/.idea/qrtool.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/cli.xml b/.idea/runConfigurations/cli.xml new file mode 100644 index 0000000..ce85c8c --- /dev/null +++ b/.idea/runConfigurations/cli.xml @@ -0,0 +1,25 @@ + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/cli_test.xml b/.idea/runConfigurations/cli_test.xml new file mode 100644 index 0000000..f78346f --- /dev/null +++ b/.idea/runConfigurations/cli_test.xml @@ -0,0 +1,25 @@ + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/cli_test_wifi.xml b/.idea/runConfigurations/cli_test_wifi.xml new file mode 100644 index 0000000..b242137 --- /dev/null +++ b/.idea/runConfigurations/cli_test_wifi.xml @@ -0,0 +1,25 @@ + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/readback_qr.xml b/.idea/runConfigurations/readback_qr.xml new file mode 100644 index 0000000..a54a8ac --- /dev/null +++ b/.idea/runConfigurations/readback_qr.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..9661ac7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..fd8caee --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,19 @@ +[tool.poetry] +name = "qrtool" +version = "0.1.0" +description = "QR Code CLI tool" +authors = ["Isaac Shoebottom "] +license = "MIT" +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.11" +segno = "^1.5.2" +click = "^8.1.3" + +[tool.poetry.scripts] +qrtool = 'qrtool.cli:cli' + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/qrtool/cli.py b/qrtool/cli.py new file mode 100644 index 0000000..06f375d --- /dev/null +++ b/qrtool/cli.py @@ -0,0 +1,47 @@ +import click +import pathlib +import segno + +from segno import helpers + +CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) + + +@click.command(context_settings=CONTEXT_SETTINGS) +# Version, Input, Output, QR Text, QR Error Correction Level, QR Border, QR Scale, WiFi Helper +@click.option('-v', '--version', is_flag=True, help="Show version") +# Output file, required +@click.option('-o', '--output', type=pathlib.Path, required=True, help="Output file") +# QR Text, required +@click.option('-t', '--text', type=str, required=False, help="QR Text") +# QR Error Correction Level, values: L, M, Q, H, -, Not required, default: L +@click.option('-e', '--error-correction', default="L", type=str, required=False, help="QR error correction level") +# Border size, default: 4, Not required +@click.option('-b', '--border', type=int, default=4, required=False, help="QR border") +# QR Scale, default: 8, Not required +@click.option('-s', '--scale', type=int, default=8, required=False, help="QR scale") +# Wi-Fi switch, Not required +@click.option('-w', '--wifi', is_flag=True, required=False, help="Wi-Fi Flag, if enabled, it will parse the encryption, ssid and password options and generate a Wi-Fi QR code. What you put is taken literally, so make sure you put the right information.") +# Encryption type, Not required +@click.option('--encryption', type=click.Choice(["WEP", "WPA", "None"], case_sensitive=False), required=False, help="Wi-Fi encryption type") +# SSID, Not required +@click.option('--ssid', type=str, required=False, help="Wi-Fi SSID") +# Password, Not required +@click.option('--password', type=str, required=False, help="Wi-Fi password") +def cli(version, output, text, error_correction, border, scale, wifi, encryption, ssid, password): + """QRTool - A simple QR code generator""" + if not text and not wifi: + print("Please provide text or Wi-Fi information") + return + if version: + print("QRTool v0.1.0") + if wifi: + text = helpers.make_wifi_data(ssid, password, encryption) + + qr = segno.make_qr(content=text, error=error_correction) + qr.save(output, border=border, scale=scale) + print("QR code saved to: " + str(output)) + + +if __name__ == '__main__': + cli()