Add starting print line
This commit is contained in:
parent
d236acb2d7
commit
227bdd5dc8
42
main.go
42
main.go
@ -1,52 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/png"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/boombuler/barcode"
|
|
||||||
|
|
||||||
"git.fjla.uk/fred.boniface/barcodes/generation"
|
|
||||||
"git.fjla.uk/fred.boniface/barcodes/validation"
|
|
||||||
"git.fjla.uk/fred.boniface/barcodes/web"
|
"git.fjla.uk/fred.boniface/barcodes/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
barcodeType := flag.String("type", "", "Barcode type (aztec, codabar, code93, code128, qr)")
|
fmt.Println("Starting `barcodes` server")
|
||||||
content := flag.String("content", "", "Barcode content")
|
|
||||||
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
if *barcodeType == "" || *content == "" {
|
|
||||||
fmt.Println("Usage: ./barcodes --type <barcode_type> --content <content>")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("Barcode Type: %s\n", *barcodeType)
|
|
||||||
fmt.Printf("Barcode Content: %s\n", *content)
|
|
||||||
|
|
||||||
validation.Validate(*content, *barcodeType)
|
|
||||||
|
|
||||||
parameters := generation.Parameters{
|
|
||||||
Format: generation.BarcodeType(*barcodeType),
|
|
||||||
ECCLevel: generation.ECCLevel(3),
|
|
||||||
Content: *content,
|
|
||||||
}
|
|
||||||
|
|
||||||
generated_barcode, err := generation.Generate(parameters)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error: ", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
generated_barcode, _ = barcode.Scale(generated_barcode, 200, 200)
|
|
||||||
|
|
||||||
file, _ := os.Create("barcode.png")
|
|
||||||
defer file.Close()
|
|
||||||
png.Encode(file, generated_barcode)
|
|
||||||
|
|
||||||
web.StartServer()
|
web.StartServer()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user