main.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright 2018 The go-ethereum Authors
  2. // This file is part of go-ethereum.
  3. //
  4. // go-ethereum is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // go-ethereum is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
  16. package main
  17. import (
  18. "os"
  19. "github.com/ethereum/go-ethereum/cmd/utils"
  20. "github.com/ethereum/go-ethereum/log"
  21. cli "gopkg.in/urfave/cli.v1"
  22. )
  23. var gitCommit string // Git SHA1 commit hash of the release (set via linker flags)
  24. // default value for "create" command --nodes flag
  25. const defaultNodes = 10
  26. func main() {
  27. err := newApp().Run(os.Args)
  28. if err != nil {
  29. log.Error(err.Error())
  30. os.Exit(1)
  31. }
  32. }
  33. // newApp construct a new instance of Swarm Snapshot Utility.
  34. // Method Run is called on it in the main function and in tests.
  35. func newApp() (app *cli.App) {
  36. app = utils.NewApp(gitCommit, "Swarm Snapshot Utility")
  37. app.Name = "swarm-snapshot"
  38. app.Usage = ""
  39. // app flags (for all commands)
  40. app.Flags = []cli.Flag{
  41. cli.IntFlag{
  42. Name: "verbosity",
  43. Value: 1,
  44. Usage: "verbosity level",
  45. },
  46. }
  47. app.Commands = []cli.Command{
  48. {
  49. Name: "create",
  50. Aliases: []string{"c"},
  51. Usage: "create a swarm snapshot",
  52. Action: create,
  53. // Flags only for "create" command.
  54. // Allow app flags to be specified after the
  55. // command argument.
  56. Flags: append(app.Flags,
  57. cli.IntFlag{
  58. Name: "nodes",
  59. Value: defaultNodes,
  60. Usage: "number of nodes",
  61. },
  62. cli.StringFlag{
  63. Name: "services",
  64. Value: "bzz",
  65. Usage: "comma separated list of services to boot the nodes with",
  66. },
  67. ),
  68. },
  69. }
  70. return app
  71. }