package main

import (
	"flag"

	"git.mousesoft.ru/ms/drawio-exporter/pkg/drawio"
)

var (
	flagHelp         bool               // Вывести справку о приложении и выйти
	flagVersion      bool               // Вывести информацию о версии приложения и выйти
	flagIgnoreErrors bool               // Игнорировать ошибки
	opts             = drawio.Options{} // Аргументы командной строки приложения
)

func init() {
	// version
	flag.BoolVar(&flagVersion, "V", false, "Prints version information")
	flag.BoolVar(&flagVersion, "version", false, "Prints version information")
	// Ignore Errors
	flag.BoolVar(&flagIgnoreErrors, "I", false, "Ignore Draw.IO errors")
	flag.BoolVar(&flagIgnoreErrors, "ignore-errors", false, "Ignore Draw.IO errors")
	// Application
	flag.StringVar(&opts.Application, "A", "", "Draw.io Desktop Application")
	flag.StringVar(&opts.Application, "application", "", "Draw.io Desktop Application")
	// EnableXvfb
	flag.BoolVar(&opts.EnableXvfb, "X", false, "Run drawio inside xvfb-run")
	flag.BoolVar(&opts.EnableXvfb, "enable-xvfb", false, "Run drawio inside xvfb-run")
	// Output
	flag.StringVar(&opts.Output, "o", "", "Exported folder name [default: export]")
	flag.StringVar(&opts.Output, "output", "", "Exported folder name [default: export]")
	// Format
	flag.Var(&opts.Format, "f",
		"Exported format [default: pdf]  [possible values: pdf, png, jpg, svg, vsdx, xml]")
	flag.Var(&opts.Format, "format",
		"Exported format [default: pdf]  [possible values: pdf, png, jpg, svg, vsdx, xml]")
	// Recursive
	flag.BoolVar(&opts.Recursive, "r", false,
		"For a folder input, recursively convert all files in sub-folders also")
	flag.BoolVar(&opts.Recursive, "recursive", false,
		"For a folder input, recursively convert all files in sub-folders also")
	// RemovePageSuffix
	flag.BoolVar(&opts.RemovePageSuffix, "remove-page-suffix", false,
		"Remove page suffix when possible (in case of single page file")
	// Quality
	flag.UintVar(&opts.Quality, "q", 0, "Output image quality for JPEG [default: 90]")
	flag.UintVar(&opts.Quality, "quality", 0, "Output image quality for JPEG [default: 90]")
	// Transparent
	flag.BoolVar(&opts.Transparent, "t", false, "Set transparent background for PNG")
	flag.BoolVar(&opts.Transparent, "transparent", false, "Set transparent background for PNG")
	// EmbedDiagram
	flag.BoolVar(&opts.EmbedDiagram, "e", false,
		"Includes a copy of the diagram for PDF, PNG, or SVG")
	flag.BoolVar(&opts.EmbedDiagram, "embed-diagram", false,
		"Includes a copy of the diagram for PDF, PNG, or SVG")
	// EmbedSvgImages
	flag.BoolVar(&opts.EmbedSvgImages, "embed-svg-images", false, "Embed Images in SVG file")
	// Border
	flag.UintVar(&opts.Border, "b", 0,
		"Sets the border width around the diagram [default: 0]")
	flag.UintVar(&opts.Border, "border", 0,
		"Sets the border width around the diagram [default: 0]")
	// Scale
	flag.UintVar(&opts.Scale, "s", 0, "Scales the diagram size")
	flag.UintVar(&opts.Scale, "scale", 0, "Scales the diagram size")
	// Width
	flag.UintVar(&opts.Width, "width", 0,
		"Fits the generated image/pdf into the specified width, preserves aspect ratio")
	// Height
	flag.UintVar(&opts.Height, "height", 0,
		"Fits the generated image/pdf into the specified height, preserves aspect ratio")
	// Crop
	flag.BoolVar(&opts.Crop, "crop", false, "Crops PDF to diagram size")
	// Uncompressed
	flag.BoolVar(&opts.Uncompressed, "u", false, "Uncompressed XML output")
	flag.BoolVar(&opts.Uncompressed, "uncompressed", false, "Uncompressed XML output")
	// EnablePlugins
	flag.BoolVar(&opts.EnablePlugins, "enable-plugins", false, "Enable Plugins")
	// help
	flag.BoolVar(&flagHelp, "h", false, "Prints help information")
	flag.BoolVar(&flagHelp, "help", false, "Prints help information")
}
