main.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright 2015 CoreOS, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // etcdctlv3 is a command line application that utilizes v3 API.
  15. package main
  16. import (
  17. "text/tabwriter"
  18. "github.com/coreos/etcd/Godeps/_workspace/src/github.com/spf13/cobra"
  19. "github.com/coreos/etcd/etcdctlv3/command"
  20. )
  21. const (
  22. cliName = "etcdctlv3"
  23. cliDescription = "A simple command line client for etcd3."
  24. )
  25. var (
  26. tabOut *tabwriter.Writer
  27. globalFlags = command.GlobalFlags{}
  28. )
  29. var (
  30. rootCmd = &cobra.Command{
  31. Use: cliName,
  32. Short: cliDescription,
  33. SuggestFor: []string{"etcctlv3", "etcdcltv3", "etlctlv3"},
  34. }
  35. )
  36. func init() {
  37. rootCmd.PersistentFlags().StringVar(&globalFlags.Endpoints, "endpoint", "127.0.0.1:2378", "gRPC endpoint")
  38. rootCmd.PersistentFlags().StringVar(&globalFlags.TLS.CertFile, "cert", "", "identify HTTPS client using this SSL certificate file")
  39. rootCmd.PersistentFlags().StringVar(&globalFlags.TLS.KeyFile, "key", "", "identify HTTPS client using this SSL key file")
  40. rootCmd.PersistentFlags().StringVar(&globalFlags.TLS.CAFile, "cacert", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
  41. rootCmd.AddCommand(
  42. command.NewRangeCommand(),
  43. command.NewPutCommand(),
  44. command.NewDeleteRangeCommand(),
  45. command.NewTxnCommand(),
  46. command.NewCompactionCommand(),
  47. command.NewWatchCommand(),
  48. command.NewVersionCommand(),
  49. command.NewLeaseCommand(),
  50. command.NewMemberCommand(),
  51. )
  52. }
  53. func init() {
  54. cobra.EnablePrefixMatching = true
  55. }
  56. func main() {
  57. rootCmd.SetUsageFunc(usageFunc)
  58. // Make help just show the usage
  59. rootCmd.SetHelpTemplate(`{{.UsageString}}`)
  60. if err := rootCmd.Execute(); err != nil {
  61. command.ExitWithError(command.ExitError, err)
  62. }
  63. }