func()

in internal/diskutil/utility.go [38:55]


func (d *DiskUtilityCmd) List(ctx context.Context, args []string) (string, error) {
	// Create the diskutil command for retrieving all disk and partition information
	//   * -plist converts diskutil's output from human-readable to the plist format
	cmdListDisks := []string{"diskutil", "list", "-plist"}

	// Append arguments to the diskutil list verb
	if len(args) > 0 {
		cmdListDisks = append(cmdListDisks, args...)
	}

	// Execute the diskutil list command and store the output
	cmdOut, err := util.ExecuteCommand(ctx, cmdListDisks, "", nil, nil)
	if err != nil {
		return cmdOut.Stdout, fmt.Errorf("diskutil: failed to run diskutil command to list all disks, stderr: [%s]: %w", cmdOut.Stderr, err)
	}

	return cmdOut.Stdout, nil
}