main.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // cryptool is a cli tool to en- or decrypt files.
  2. //
  3. // NAME:
  4. // cryptool - the crypto helper
  5. //
  6. // USAGE:
  7. // cryptool [global options] command [command options] [arguments...]
  8. //
  9. // VERSION:
  10. // 0.1
  11. //
  12. // COMMANDS:
  13. // encrypt, enc encrypt a file using a public key
  14. // decrypt, dec decrypt a file using a private key
  15. // help, h Shows a list of commands or help for one command
  16. //
  17. // GLOBAL OPTIONS:
  18. // --out, -o ouput filename to use
  19. // --version, -v print the version
  20. // --help, -h show help
  21. package main
  22. import (
  23. "os"
  24. "github.com/codegangsta/cli"
  25. "github.com/cryptix/go/logging"
  26. kitlog "github.com/go-kit/kit/log"
  27. )
  28. var log *kitlog.Context
  29. func main() {
  30. app := cli.NewApp()
  31. app.Name = "cryptool"
  32. app.Usage = "the crypto helper"
  33. app.Version = "0.1"
  34. app.Flags = []cli.Flag{
  35. cli.StringFlag{Name: "out, o", Usage: "ouput filename to use"},
  36. }
  37. app.Commands = []cli.Command{
  38. {
  39. Name: "encrypt",
  40. ShortName: "enc",
  41. Usage: "encrypt a file using it's hash as the key",
  42. Action: runEnc,
  43. },
  44. {
  45. Name: "decrypt",
  46. ShortName: "dec",
  47. Usage: "decrypt a file",
  48. Action: runDec,
  49. Flags: []cli.Flag{
  50. cli.StringFlag{Name: "key, k", Usage: "the key for the file, in hex"},
  51. },
  52. },
  53. }
  54. logging.SetupLogging(nil)
  55. log = logging.Logger(app.Name)
  56. app.Run(os.Args)
  57. }