func validateOptions() {
	errsDir := options.GetS(OPT_ERROR_DIR)
	if errsDir != "" {
		switch {
		case !fsutil.IsExist(errsDir):
			printErrorAndExit("Directory %s doesn't exist", errsDir)
		case !fsutil.IsDir(errsDir):
			printErrorAndExit("Object %s is not a directory", errsDir)
		case !fsutil.IsWritable(errsDir):
			printErrorAndExit("Directory %s is not writable", errsDir)
		}
	}
	wrkDir := options.GetS(OPT_DIR)
	if wrkDir != "" {
		switch {
		case !fsutil.IsExist(wrkDir):
			printErrorAndExit("Directory %s doesn't exist", wrkDir)
		case !fsutil.IsDir(wrkDir):
			printErrorAndExit("Object %s is not a directory", wrkDir)
		}
	}
}
validateOptions validates options
package cli
import (
	"fmt"
	"os"
	"path/filepath"
	"strings"
	"pkg.re/essentialkaos/ek.v12/fmtc"
	"pkg.re/essentialkaos/ek.v12/fmtutil"
	"pkg.re/essentialkaos/ek.v12/fsutil"
	"pkg.re/essentialkaos/ek.v12/options"
	"pkg.re/essentialkaos/ek.v12/req"
	"pkg.re/essentialkaos/ek.v12/strutil"
	"pkg.re/essentialkaos/ek.v12/usage"
	"pkg.re/essentialkaos/ek.v12/usage/completion/bash"
	"pkg.re/essentialkaos/ek.v12/usage/completion/fish"
	"pkg.re/essentialkaos/ek.v12/usage/completion/zsh"
	"pkg.re/essentialkaos/ek.v12/usage/man"
	"pkg.re/essentialkaos/ek.v12/usage/update"
	"github.com/essentialkaos/bibop/cli/executor"
	"github.com/essentialkaos/bibop/parser"
	"github.com/essentialkaos/bibop/recipe"
	"github.com/essentialkaos/bibop/render"
)
const (
	APP  = "bibop"
	VER  = "4.8.0"
	DESC = "Utility for testing command-line tools"
)
const (
	OPT_DRY_RUN         = "D:dry-run"
	OPT_LIST_PACKAGES   = "L:list-packages"
	OPT_FORMAT          = "f:format"
	OPT_DIR             = "d:dir"
	OPT_PATH            = "p:path"
	OPT_ERROR_DIR       = "e:error-dir"
	OPT_TAG             = "t:tag"
	OPT_QUIET           = "q:quiet"
	OPT_INGORE_PACKAGES = "ip:ignore-packages"
	OPT_NO_CLEANUP      = "nl:no-cleanup"
	OPT_NO_COLOR        = "nc:no-color"
	OPT_HELP            = "h:help"
	OPT_VER             = "v:version"
	OPT_COMPLETION   = "completion"
	OPT_GENERATE_MAN = "generate-man"
)
var optMap = options.Map{
	OPT_DRY_RUN:         {Type: options.BOOL},
	OPT_LIST_PACKAGES:   {Type: options.BOOL},
	OPT_FORMAT:          {},
	OPT_DIR:             {},
	OPT_PATH:            {},
	OPT_ERROR_DIR:       {},
	OPT_TAG:             {Mergeble: true},
	OPT_QUIET:           {Type: options.BOOL},
	OPT_INGORE_PACKAGES: {Type: options.BOOL},
	OPT_NO_CLEANUP:      {Type: options.BOOL},
	OPT_NO_COLOR:        {Type: options.BOOL},
	OPT_HELP:            {Type: options.BOOL, Alias: "u:usage"},
	OPT_VER:             {Type: options.BOOL, Alias: "ver"},
	OPT_COMPLETION:   {},
	OPT_GENERATE_MAN: {Type: options.BOOL},
}
func Init() {
	args, errs := options.Parse(optMap)
	if len(errs) != 0 {
		for _, err := range errs {
			printError(err.Error())
		}
		os.Exit(1)
	}
	if options.Has(OPT_COMPLETION) {
		os.Exit(genCompletion())
	}
	if options.Has(OPT_GENERATE_MAN) {
		os.Exit(genMan())
	}
	configureUI()
	configureSubsystems()
	if options.GetB(OPT_VER) {
		showAbout()
		os.Exit(0)
	}
	if options.GetB(OPT_HELP) || len(args) == 0 {
		showUsage()
		os.Exit(0)
	}
	validateOptions()
	process(args[0])
}
func configureUI() {
	if options.GetB(OPT_NO_COLOR) {
		fmtc.DisableColors = true
	}
	if os.Getenv("CI") == "" {
		fmtutil.SeparatorFullscreen = true
	}
	fmtutil.SeparatorSymbol = "–"
	if fmtc.Is256ColorsSupported() {
		fmtutil.SeparatorTitleColorTag = "{#85}"
	} else {
		fmtutil.SeparatorTitleColorTag = "{c*}"
	}
}
func configureSubsystems() {
	req.Global.SetUserAgent(APP, VER)
	if !options.Has(OPT_PATH) {
		return
	}
	pathOpt, err := filepath.Abs(options.GetS(OPT_PATH))
	if err != nil {
		printErrorAndExit(err.Error())
	}
	newPath := os.Getenv("PATH") + ":" + pathOpt
	err = os.Setenv("PATH", newPath)
	if err != nil {
		printErrorAndExit(err.Error())
	}
}