main.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (C) 2014 Audrius Butkevičius
  2. package main
  3. import (
  4. "sort"
  5. "github.com/AudriusButkevicius/cli"
  6. )
  7. type ByAlphabet []cli.Command
  8. func (a ByAlphabet) Len() int { return len(a) }
  9. func (a ByAlphabet) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
  10. func (a ByAlphabet) Less(i, j int) bool { return a[i].Name < a[j].Name }
  11. var cliCommands []cli.Command
  12. func main() {
  13. app := cli.NewApp()
  14. app.Name = "syncthing-cli"
  15. app.Author = "Audrius Butkevičius"
  16. app.Email = "[email protected]"
  17. app.Usage = "Syncthing command line interface"
  18. app.Version = "0.1"
  19. app.HideHelp = true
  20. app.Flags = []cli.Flag{
  21. cli.StringFlag{
  22. Name: "endpoint, e",
  23. Value: "http://127.0.0.1:8384",
  24. Usage: "End point to connect to",
  25. EnvVar: "STENDPOINT",
  26. },
  27. cli.StringFlag{
  28. Name: "apikey, k",
  29. Value: "",
  30. Usage: "API Key",
  31. EnvVar: "STAPIKEY",
  32. },
  33. cli.StringFlag{
  34. Name: "username, u",
  35. Value: "",
  36. Usage: "Username",
  37. EnvVar: "STUSERNAME",
  38. },
  39. cli.StringFlag{
  40. Name: "password, p",
  41. Value: "",
  42. Usage: "Password",
  43. EnvVar: "STPASSWORD",
  44. },
  45. cli.BoolFlag{
  46. Name: "insecure, i",
  47. Usage: "Do not verify SSL certificate",
  48. EnvVar: "STINSECURE",
  49. },
  50. }
  51. sort.Sort(ByAlphabet(cliCommands))
  52. app.Commands = cliCommands
  53. app.RunAndExitOnError()
  54. }