Example #1
0
// mainShare - main handler for mc share command
func mainShare(ctx *cli.Context) {
	if !ctx.Args().Present() || ctx.Args().First() == "help" {
		cli.ShowAppHelp(ctx)
	}

	// sub-commands like "upload" and "download" have their own main.
}
Example #2
0
func mainControl(ctx *cli.Context) {
	if ctx.Args().First() != "" { // command help.
		cli.ShowCommandHelp(ctx, ctx.Args().First())
	} else {
		// command with Subcommands is an App.
		cli.ShowAppHelp(ctx)
	}
}
Example #3
0
// mainShare - main handler for mc share command.
func mainShare(ctx *cli.Context) {
	// Set global flags from context.
	setGlobalsFromContext(ctx)

	if ctx.Args().First() != "" { // command help.
		cli.ShowCommandHelp(ctx, ctx.Args().First())
	} else { // mc help.
		cli.ShowAppHelp(ctx)
	}

	// Sub-commands like "upload" and "download" have their own main.
}
Example #4
0
// mainConfig is the handle for "mc config" command. provides sub-commands which write configuration data in json format to config file.
func mainConfig(ctx *cli.Context) {
	// Set global flags from context.
	setGlobalsFromContext(ctx)

	if ctx.Args().First() != "" { // command help.
		cli.ShowCommandHelp(ctx, ctx.Args().First())
	} else {
		// command with Subcommands is an App.
		cli.ShowAppHelp(ctx)
	}

	// Sub-commands like "host" and "alias" have their own main.
}
Example #5
0
// mainEvents is the handle for "mc events" command.
func mainEvents(ctx *cli.Context) error {
	// Set global flags from context.
	setGlobalsFromContext(ctx)

	if ctx.Args().First() != "" { // command help.
		cli.ShowCommandHelp(ctx, ctx.Args().First())
	} else {
		// command with Subcommands is an App.
		cli.ShowAppHelp(ctx)
	}

	return nil
	// Sub-commands like "add", "remove", "list" have their own main.
}
Example #6
0
File: main.go Project: flandr/minio
func runMkdonut(c *cli.Context) {
	if !c.Args().Present() || c.Args().First() == "help" {
		cli.ShowAppHelp(c)
		os.Exit(1)
	}
	donutName := c.Args().First()
	if c.Args().First() != "" {
		if !donut.IsValidDonut(donutName) {
			Fatalf("Invalid donutname %s\n", donutName)
		}
	}
	var disks []string
	for _, disk := range c.Args().Tail() {
		if _, err := isUsable(disk); err != nil {
			Fatalln(err)
		}
		disks = append(disks, disk)
	}
	for _, disk := range disks {
		if err := os.MkdirAll(filepath.Join(disk, donutName), 0700); err != nil {
			Fatalln(err)
		}
	}

	hostname, err := os.Hostname()
	if err != nil {
		Fatalln(err)
	}
	donutConfig := &donut.Config{}
	donutConfig.Version = "0.0.1"
	donutConfig.DonutName = donutName
	donutConfig.NodeDiskMap = make(map[string][]string)
	// keep it in exact order as it was specified, do not try to sort disks
	donutConfig.NodeDiskMap[hostname] = disks
	// default cache is unlimited
	donutConfig.MaxSize = 0

	if err := donut.SaveConfig(donutConfig); err != nil {
		Fatalln(err)
	}

	Infoln("Success!")
}
Example #7
0
func registerApp() *cli.App {
	// Register all the commands (refer flags.go)
	registerCmd(lsCmd)      // List contents of a bucket.
	registerCmd(mbCmd)      // Make a bucket.
	registerCmd(catCmd)     // Display contents of a file.
	registerCmd(pipeCmd)    // Write contents of stdin to a file.
	registerCmd(shareCmd)   // Share documents via URL.
	registerCmd(cpCmd)      // Copy objects and files from multiple sources to single destination.
	registerCmd(mirrorCmd)  // Mirror objects and files from single source to multiple destinations.
	registerCmd(diffCmd)    // Computer differences between two files or folders.
	registerCmd(rmCmd)      // Remove a file or bucket
	registerCmd(eventsCmd)  // Add events cmd
	registerCmd(watchCmd)   // Add watch cmd
	registerCmd(policyCmd)  // Set policy permissions.
	registerCmd(sessionCmd) // Manage sessions for copy and mirror.
	registerCmd(configCmd)  // Configure minio client.
	registerCmd(updateCmd)  // Check for new software updates.
	registerCmd(versionCmd) // Print version.

	app := cli.NewApp()
	app.Action = func(ctx *cli.Context) {
		if strings.HasPrefix(Version, "RELEASE.") {
			updateMsg, _, err := getReleaseUpdate(mcUpdateStableURL)
			if err != nil {
				// Ignore any errors during getReleaseUpdate() because
				// the internet might not be available.
				return
			}
			if updateMsg.Update {
				printMsg(updateMsg)
			}
		}
		cli.ShowAppHelp(ctx)
	}
	app.Usage = "Minio Client for cloud storage and filesystems."
	app.Commands = commands
	app.Author = "Minio.io"
	app.Flags = append(mcFlags, globalFlags...)
	app.CustomAppHelpTemplate = mcHelpTemplate
	app.CommandNotFound = commandNotFound // handler function declared above.
	return app
}
Example #8
0
// mainConfig is the handle for "mc config" command. provides sub-commands which write configuration data in json format to config file.
func mainConfig(ctx *cli.Context) {
	if !ctx.Args().Present() || ctx.Args().First() == "help" {
		cli.ShowAppHelp(ctx)
	}
}