main.go 691 B

123456789101112131415161718192021222324252627282930313233
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "github.com/pierrec/cmdflag"
  6. )
  7. func main() {
  8. flag.CommandLine.Bool(cmdflag.VersionBoolFlag, false, "print the program version")
  9. cli := cmdflag.New(nil)
  10. cli.MustAdd(cmdflag.Application{
  11. Name: "compress",
  12. Args: "[arguments] [<file name> ...]",
  13. Descr: "Compress the given files or from stdin to stdout.",
  14. Err: flag.ExitOnError,
  15. Init: Compress,
  16. })
  17. cli.MustAdd(cmdflag.Application{
  18. Name: "uncompress",
  19. Args: "[arguments] [<file name> ...]",
  20. Descr: "Uncompress the given files or from stdin to stdout.",
  21. Err: flag.ExitOnError,
  22. Init: Uncompress,
  23. })
  24. if err := cli.Parse(); err != nil {
  25. fmt.Println(err)
  26. return
  27. }
  28. }