1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
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 <file> encrypt a file\n")
fmt.Fprintf(os.Stderr, " decrypt | d <file> decrypt a file\n")
os.Exit(1)
}
|