Exemplo n.º 1
0
func main() {
	app := cli.NewApp()
	app.Usage = "Update ipfs."
	app.Version = config.CurrentVersionNumber

	app.Flags = []cli.Flag{
		cli.BoolFlag{
			Name:  "verbose",
			Usage: "Print verbose output.",
		},
		cli.StringFlag{
			Name:  "distpath",
			Usage: "specify the distributions build to use",
		},
	}

	app.Before = func(c *cli.Context) error {
		stump.Verbose = c.Bool("verbose")
		if distp := c.String("distpath"); distp != "" {
			util.IpfsVersionPath = distp
		}
		return nil
	}

	app.Commands = []cli.Command{
		cmdVersions,
		cmdVersion,
		cmdInstall,
		cmdStash,
		cmdRevert,
		cmdFetch,
	}

	if err := app.Run(os.Args); err != nil {
		stump.Fatal(err)
	}
}
Exemplo n.º 2
0
		cmdFetch,
	}

	if err := app.Run(os.Args); err != nil {
		stump.Fatal(err)
	}
}

var cmdVersions = cli.Command{
	Name:      "versions",
	Usage:     "Print out all available versions.",
	ArgsUsage: " ",
	Action: func(c *cli.Context) error {
		vs, err := GetVersions(util.IpfsVersionPath, "go-ipfs")
		if err != nil {
			stump.Fatal("failed to query versions: ", err)
		}

		for _, v := range vs {
			fmt.Println(v)
		}

		return nil
	},
}

var cmdVersion = cli.Command{
	Name:  "version",
	Usage: "Print out currently installed version.",
	Action: func(c *cli.Context) error {
		v, err := GetCurrentVersion()