package main import ( "flag" "os" "fmt" ) var ( rawEncrypt bool rawDecrypt bool ) var commands = map[string]*flag.FlagSet{} func initFlags() { // Raw Encrypt encryptCmd := flag.NewFlagSet("encrypt", flag.ExitOnError) encryptCmd.BoolVar(&rawEncrypt, "encrypt", true, "encrypt a UTF8 file") encryptCmd.BoolVar(&rawEncrypt, "e", true, "encrypt a UTF-8 file") commands["encrypt"] = encryptCmd // Raw Decrypt decryptCmd := flag.NewFlagSet("decrypt", flag.ExitOnError) decryptCmd.BoolVar(&rawDecrypt, "decrypt", false, "decrypt a UTF8 file") decryptCmd.BoolVar(&rawDecrypt, "d", false, "decrypt a UTF-8 file") commands["decrypt"] = decryptCmd } func usage() { fmt.Fprintf(os.Stderr, "Usage:\n") fmt.Fprintf(os.Stderr, " encrypt | e encrypt a file\n") fmt.Fprintf(os.Stderr, " decrypt | d decrypt a file\n") os.Exit(1) }