main.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. var gitDate string
  25. // default value for "create" command --nodes flag
  26. const defaultNodes = 8
  27. func main() {
  28. err := newApp().Run(os.Args)
  29. if err != nil {
  30. log.Error(err.Error())
  31. os.Exit(1)
  32. }
  33. }
  34. // newApp construct a new instance of Swarm Snapshot Utility.
  35. // Method Run is called on it in the main function and in tests.
  36. func newApp() (app *cli.App) {
  37. app = utils.NewApp(gitCommit, gitDate, "Swarm Snapshot Utility")
  38. app.Name = "swarm-snapshot"
  39. app.Usage = ""
  40. // app flags (for all commands)
  41. app.Flags = []cli.Flag{
  42. cli.IntFlag{
  43. Name: "verbosity",
  44. Value: 1,
  45. Usage: "verbosity level",
  46. },
  47. }
  48. app.Commands = []cli.Command{
  49. {
  50. Name: "create",
  51. Aliases: []string{"c"},
  52. Usage: "create a swarm snapshot",
  53. Action: create,
  54. // Flags only for "create" command.
  55. // Allow app flags to be specified after the
  56. // command argument.
  57. Flags: append(app.Flags,
  58. cli.IntFlag{
  59. Name: "nodes",
  60. Value: defaultNodes,
  61. Usage: "number of nodes",
  62. },
  63. cli.StringFlag{
  64. Name: "services",
  65. Value: "bzz",
  66. Usage: "comma separated list of services to boot the nodes with",
  67. },
  68. ),
  69. },
  70. }
  71. return app
  72. }