func()

in oss/lib/restore.go [326:357]


func (rc *RestoreCommand) checkOptions(cloudURL CloudURL, recursive, force bool, versionid, objectFile string) error {
	if cloudURL.bucket == "" {
		return fmt.Errorf("invalid cloud url: %s, miss bucket", cloudURL.urlStr)
	}
	if cloudURL.object == "" {
		if !recursive && objectFile == "" {
			return fmt.Errorf("restore object invalid cloud url: %s, object empty. Restore bucket is not supported, if you mean batch restore objects, please use --recursive or --object-file", rc.command.args[0])
		}
	} else {
		if objectFile != "" {
			return fmt.Errorf("the first arg of `ossutil restore` only support oss://bucket when set option --object-file")
		}
	}

	if (recursive && len(versionid) > 0) || (objectFile != "" && len(versionid) > 0) {
		return fmt.Errorf("restore bucket dose not support the --version-id=%s argument.", versionid)
	}

	if !force {
		var val string
		if !recursive && objectFile == "" {
			return nil
		}
		fmt.Printf("Do you really mean to recursivlly restore objects of %s(y or N)? ", rc.command.args[0])
		if _, err := fmt.Scanln(&val); err != nil || (strings.ToLower(val) != "yes" && strings.ToLower(val) != "y") {
			fmt.Println("operation is canceled.")
			return nil
		}
	}

	return nil
}