### Command Line Usage for QRTerminal Source: https://context7.com/mdp/qrterminal/llms.txt Provides examples of using the qrterminal CLI tool to generate QR codes from URLs or piped input, including flag configurations and Docker usage. ```bash qrterminal https://github.com/mdp/qrterminal qrterminal -l M https://example.com qrterminal -q 4 https://example.com qrterminal -v https://example.com qrterminal -s https://example.com echo "Hello World" | qrterminal cat wireguard.conf | qrterminal docker run --rm ghcr.io/mdp/qrterminal:latest 'https://github.com' cat config.txt | docker run --rm -i ghcr.io/mdp/qrterminal:latest ``` -------------------------------- ### Configure QR Code Generation in Go Source: https://context7.com/mdp/qrterminal/llms.txt Demonstrates how to use the Config struct to customize QR code output, including error correction, output writers, and character rendering. It also shows how to capture generated QR codes into a buffer. ```go package main import ( "bytes" "fmt" "os" "github.com/mdp/qrterminal/v3" ) func main() { config := qrterminal.Config{ Level: qrterminal.H, Writer: os.Stdout, HalfBlocks: true, BlackChar: qrterminal.BLACK_BLACK, WhiteChar: qrterminal.WHITE_WHITE, BlackWhiteChar: qrterminal.BLACK_WHITE, WhiteBlackChar: qrterminal.WHITE_BLACK, QuietZone: 4, WithSixel: false, } qrterminal.GenerateWithConfig("https://github.com", config) var buf bytes.Buffer bufConfig := qrterminal.Config{ Level: qrterminal.L, Writer: &buf, BlackChar: qrterminal.BLACK, WhiteChar: qrterminal.WHITE, QuietZone: 2, } qrterminal.GenerateWithConfig("captured output", bufConfig) fmt.Printf("QR code has %d bytes\n", buf.Len()) } ``` -------------------------------- ### Generate Basic QR Code in Go Source: https://github.com/mdp/qrterminal/blob/main/README.md Generates a QR code with default settings (Low error correction) and writes it to standard output. This is the simplest way to use the library. ```go import ( "github.com/mdp/qrterminal/v3" "os" ) func main() { // Generate a 'dense' qrcode with the 'Low' level error correction and write it to Stdout qrterminal.Generate("https://github.com/mdp/qrterminal", qrterminal.L, os.Stdout) } ``` -------------------------------- ### Use Custom Character Constants in Go Source: https://context7.com/mdp/qrterminal/llms.txt Demonstrates utilizing pre-defined constants for ANSI colors and Unicode half-blocks to control the visual appearance of rendered QR codes. ```go package main import ( "os" "github.com/mdp/qrterminal/v3" ) func main() { config := qrterminal.Config{ Level: qrterminal.L, Writer: os.Stdout, BlackChar: qrterminal.BLACK, WhiteChar: qrterminal.WHITE, QuietZone: qrterminal.QUIET_ZONE, } qrterminal.GenerateWithConfig("https://example.com", config) } ``` -------------------------------- ### Detect Sixel Graphics Support in Go Source: https://context7.com/mdp/qrterminal/llms.txt Shows how to use IsSixelSupported to conditionally render QR codes as bitmap images if the terminal environment supports Sixel graphics. ```go package main import ( "fmt" "os" "github.com/mdp/qrterminal/v3" ) func main() { if qrterminal.IsSixelSupported(os.Stdout) { fmt.Println("Sixel supported - using bitmap rendering") config := qrterminal.Config{ Level: qrterminal.L, Writer: os.Stdout, WithSixel: true, QuietZone: 2, } qrterminal.GenerateWithConfig("https://github.com", config) } else { fmt.Println("Using ASCII/Unicode rendering") qrterminal.Generate("https://github.com", qrterminal.L, os.Stdout) } } ``` -------------------------------- ### Generate Function - Basic QR Code Generation Source: https://context7.com/mdp/qrterminal/llms.txt The `Generate` function provides a simple way to create a QR code. It encodes the provided string, uses a specified error correction level, and writes the output to an `io.Writer`. It automatically handles Sixel graphics support. ```APIDOC ## Generate Function ### Description Generates a QR code from the given data with a specified error correction level and writes it to the provided `io.Writer`. Automatically detects and uses Sixel graphics if supported by the terminal. ### Method `Generate(content string, level qrterminal.ErrorCorrectionLevel, writer io.Writer)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```go package main import ( "os" "github.com/mdp/qrterminal/v3" ) func main() { // Generate a basic QR code with Low error correction to stdout qrterminal.Generate("https://github.com/mdp/qrterminal", qrterminal.L, os.Stdout) // Generate with Medium error correction for better resilience qrterminal.Generate("https://example.com", qrterminal.M, os.Stdout) // Generate with High error correction for maximum redundancy qrterminal.Generate("wifi:WPA;S:MyNetwork;P:MyPassword;;", qrterminal.H, os.Stdout) } ``` ### Response #### Success Response (200) QR code rendered to the specified `io.Writer`. #### Response Example (Terminal output of a QR code) ``` -------------------------------- ### Generate Basic QR Code in Go Source: https://context7.com/mdp/qrterminal/llms.txt The Generate function creates a QR code with specified error correction level and outputs it to an io.Writer. It automatically handles Sixel graphics support for compatible terminals. This is the simplest method for QR code generation. ```Go package main import ( "os" "github.com/mdp/qrterminal/v3" ) func main() { // Generate a basic QR code with Low error correction to stdout qrterminal.Generate("https://github.com/mdp/qrterminal", qrterminal.L, os.Stdout) // Generate with Medium error correction for better resilience qrterminal.Generate("https://example.com", qrterminal.M, os.Stdout) // Generate with High error correction for maximum redundancy qrterminal.Generate("wifi:WPA;S:MyNetwork;P:MyPassword;;", qrterminal.H, os.Stdout) } ``` -------------------------------- ### Generate QR Code with Custom Configuration in Go Source: https://context7.com/mdp/qrterminal/llms.txt The GenerateWithConfig function offers extensive customization for QR code generation using a Config struct. This allows modification of characters, colors, quiet zone size, and rendering mode (including half-block support). ```Go package main import ( "os" "github.com/mdp/qrterminal/v3" ) func main() { // Inverted colors (white on black terminal) invertedConfig := qrterminal.Config{ Level: qrterminal.M, Writer: os.Stdout, BlackChar: qrterminal.WHITE, WhiteChar: qrterminal.BLACK, QuietZone: 1, } qrterminal.GenerateWithConfig("https://github.com/mdp/qrterminal", invertedConfig) // Half-block mode with custom quiet zone halfBlockConfig := qrterminal.Config{ Level: qrterminal.M, Writer: os.Stdout, HalfBlocks: true, QuietZone: 3, } qrterminal.GenerateWithConfig("https://example.com", halfBlockConfig) // Custom ASCII characters for non-ANSI terminals asciiConfig := qrterminal.Config{ Level: qrterminal.L, Writer: os.Stdout, BlackChar: "##", WhiteChar: " ", QuietZone: 2, } qrterminal.GenerateWithConfig("plain text data", asciiConfig) } ``` -------------------------------- ### Set Error Correction Levels in Go Source: https://context7.com/mdp/qrterminal/llms.txt Explains the three error correction levels (L, M, H) available in the library, which balance QR code size against data recovery resilience. ```go package main import ( "os" "github.com/mdp/qrterminal/v3" ) func main() { url := "https://example.com" qrterminal.Generate(url, qrterminal.L, os.Stdout) qrterminal.Generate(url, qrterminal.M, os.Stdout) qrterminal.Generate(url, qrterminal.H, os.Stdout) } ``` -------------------------------- ### Generate QR Code with Custom Configuration in Go Source: https://github.com/mdp/qrterminal/blob/main/README.md Generates a QR code with custom configuration options, including error correction level, custom characters for black and white blocks, and quiet zone size. This allows for more control over the QR code's appearance and data integrity. ```go import ( "github.com/mdp/qrterminal/v3" "os" ) func main() { config := qrterminal.Config{ Level: qrterminal.M, Writer: os.Stdout, BlackChar: qrterminal.WHITE, WhiteChar: qrterminal.BLACK, QuietZone: 1, } qrterminal.GenerateWithConfig("https://github.com/mdp/qrterminal", config) } ``` -------------------------------- ### GenerateWithConfig Function - Customizable QR Code Generation Source: https://context7.com/mdp/qrterminal/llms.txt The `GenerateWithConfig` function offers extensive customization options for QR code generation via a `Config` struct, allowing control over characters, colors, quiet zone, and rendering mode. ```APIDOC ## GenerateWithConfig Function ### Description Generates a QR code with full control over its appearance and rendering using a `Config` struct. Allows customization of error correction level, characters for black/white pixels, quiet zone size, and rendering mode (including half-blocks). ### Method `GenerateWithConfig(content string, config qrterminal.Config)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```go package main import ( "os" "github.com/mdp/qrterminal/v3" ) func main() { // Inverted colors (white on black terminal) invertedConfig := qrterminal.Config{ Level: qrterminal.M, Writer: os.Stdout, BlackChar: qrterminal.WHITE, WhiteChar: qrterminal.BLACK, QuietZone: 1, } qrterminal.GenerateWithConfig("https://github.com/mdp/qrterminal", invertedConfig) // Half-block mode with custom quiet zone halfBlockConfig := qrterminal.Config{ Level: qrterminal.M, Writer: os.Stdout, HalfBlocks: true, QuietZone: 3, } qrterminal.GenerateWithConfig("https://example.com", halfBlockConfig) // Custom ASCII characters for non-ANSI terminals asciiConfig := qrterminal.Config{ Level: qrterminal.L, Writer: os.Stdout, BlackChar: "##", WhiteChar: " ", QuietZone: 2, } qrterminal.GenerateWithConfig("plain text data", asciiConfig) } ``` ### Response #### Success Response (200) Customized QR code rendered to the `Writer` specified in the `Config`. #### Response Example (Terminal output of a customized QR code) ``` -------------------------------- ### Generate Half-Block QR Code in Go Source: https://github.com/mdp/qrterminal/blob/main/README.md Generates a QR code using 'half blocks' for a more compact representation in the terminal. This option, combined with medium error correction, provides a smaller yet readable QR code. ```go import ( "github.com/mdp/qrterminal/v3" "os" ) func main() { config := qrterminal.Config{ HalfBlocks: true, Level: qrterminal.M, Writer: os.Stdout, } qrterminal.GenerateWithConfig("https://github.com/mdp/qrterminal", config) } ``` -------------------------------- ### Generate Compact Half-Block QR Code in Go Source: https://context7.com/mdp/qrterminal/llms.txt The GenerateHalfBlock function generates a more compact QR code using Unicode half-block characters, resulting in output that is approximately half the height of standard rendering. It accepts the data to encode, error correction level, and an io.Writer for output. ```Go package main import ( "os" "github.com/mdp/qrterminal/v3" ) func main() { // Generate a compact half-block QR code qrterminal.GenerateHalfBlock("https://github.com/mdp/qrterminal", qrterminal.L, os.Stdout) // Half-block with Medium error correction qrterminal.GenerateHalfBlock("https://example.com/path?param=value", qrterminal.M, os.Stdout) } ``` -------------------------------- ### GenerateHalfBlock Function - Compact QR Code Generation Source: https://context7.com/mdp/qrterminal/llms.txt The `GenerateHalfBlock` function generates a more compact QR code using Unicode half-block characters, resulting in output that is approximately half the height of the standard rendering. ```APIDOC ## GenerateHalfBlock Function ### Description Generates a compact QR code using Unicode half-block characters (▄, ▀, █), resulting in a smaller terminal output. ### Method `GenerateHalfBlock(content string, level qrterminal.ErrorCorrectionLevel, writer io.Writer)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```go package main import ( "os" "github.com/mdp/qrterminal/v3" ) func main() { // Generate a compact half-block QR code qrterminal.GenerateHalfBlock("https://github.com/mdp/qrterminal", qrterminal.L, os.Stdout) // Half-block with Medium error correction qrterminal.GenerateHalfBlock("https://example.com/path?param=value", qrterminal.M, os.Stdout) } ``` ### Response #### Success Response (200) Compact QR code rendered to the specified `io.Writer`. #### Response Example (Terminal output of a compact QR code) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.