// outputList format.
969965
func outputList() {
	fmt.Println()
	for _, fn := range root.Project.Functions {
		awsFn, err := fn.GetConfigCurrent()

		if awserr, ok := err.(awserr.Error); ok && awserr.Code() == "ResourceNotFoundException" {
			fmt.Printf("  \033[%dm%s\033[0m (not deployed) \n", colors.Blue, fn.Name)
		} else {
			fmt.Printf("  \033[%dm%s\033[0m\n", colors.Blue, fn.Name)
		}

		if fn.Description != "" {
			fmt.Printf("    description: %v\n", fn.Description)
		}
		fmt.Printf("    runtime: %v\n", fn.Runtime)
		fmt.Printf("    memory: %vmb\n", fn.Memory)
		fmt.Printf("    timeout: %vs\n", fn.Timeout)
		fmt.Printf("    role: %v\n", fn.Role)
		fmt.Printf("    handler: %v\n", fn.Handler)
		if awsFn != nil && awsFn.Configuration != nil && awsFn.Configuration.FunctionArn != nil {
			fmt.Printf("    arn: %v\n", *awsFn.Configuration.FunctionArn)
		}

		if err != nil {
			fmt.Println()
			continue // ignore
		}

		aliaslist, err := fn.GetAliases()
		if err != nil {
			continue
		}

		var aliases string
		for index, alias := range aliaslist.Aliases {
			if index > 0 {
				aliases += ", "
			}
			aliases += fmt.Sprintf("%s@v%s", *alias.Name, *alias.FunctionVersion)
		}
		if aliases == "" {
			aliases = "<none>"
		}
		fmt.Printf("    aliases: %s\n", aliases)
		fmt.Println()
	}
}
493911
func formatList(in []string) string {
	columnConf := columnize.DefaultConfig()
	columnConf.Empty = "<none>"
	return columnize.Format(in, columnConf)
}
801994
func (r *Rets) PrintList() string {
	return join(r.ToParams(), func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
}
883480
func FormatStringList(list []string) (fields []interface{}) {
	fields = make([]interface{}, len(list))
	for i, v := range list {
		fields[i] = v
	}
	return
}
315047
func (p *iscsiProvisioner) exportList() (exportList, error) {
	client, err := p.getConnection()
	defer client.Close()
	if err != nil {
		log.Warnln(err)
		return nil, err
	}
	var result1 exportList
	err = client.Call("export_list", nil, &result1)
	return result1, err
}
1061478
func EncodeList(e Encoder, objects []Object) error {
	var errs []error
	for i := range objects {
		data, err := Encode(e, objects[i])
		if err != nil {
			errs = append(errs, err)
			continue
		}
		// TODO: Set ContentEncoding and ContentType.
		objects[i] = &Unknown{Raw: data}
	}
	return errors.NewAggregate(errs)
}
293467
func (list *Lists) GenerateFilelist(out io.Writer) error {
	w := bufio.NewWriter(out)
	for _, pair := range list.getPairs() {
		dLen := len(*pair.data)
		toWrite := []string{
			pair.kind,
			"\n(",
			strconv.Itoa(dLen),
			")\n",
		}
		if dLen > 0 {
			toWrite = append(toWrite,
				strings.Join(*pair.data, "\n"),
				"\n")
		}
		toWrite = append(toWrite, "\n")
		for _, str := range toWrite {
			if _, err := w.WriteString(str); err != nil {
				return err
			}
		}
	}
	w.Flush()
	return nil
}
1160554
func NewErrorOutput(format string, v ...interface{}) OutputModel {
	return OutputModel{
		Error: fmt.Sprintf(format, v...),
	}
}
109826
func loadOutputsHcl(list *ast.ObjectList) ([]*Output, error) {
	if err := assertAllBlocksHaveNames("output", list); err != nil {
		return nil, err
	}

	list = list.Children()

	// Go through each object and turn it into an actual result.
	result := make([]*Output, 0, len(list.Items))
	for _, item := range list.Items {
		n := item.Keys[0].Token.Value().(string)

		var listVal *ast.ObjectList
		if ot, ok := item.Val.(*ast.ObjectType); ok {
			listVal = ot.List
		} else {
			return nil, fmt.Errorf("output '%s': should be an object", n)
		}

		var config map[string]interface{}
		if err := hcl.DecodeObject(&config, item.Val); err != nil {
			return nil, err
		}

		// Delete special keys
		delete(config, "depends_on")
		delete(config, "description")

		rawConfig, err := NewRawConfig(config)
		if err != nil {
			return nil, fmt.Errorf(
				"Error reading config for output %s: %s",
				n,
				err)
		}

		// If we have depends fields, then add those in
		var dependsOn []string
		if o := listVal.Filter("depends_on"); len(o.Items) > 0 {
			err := hcl.DecodeObject(&dependsOn, o.Items[0].Val)
			if err != nil {
				return nil, fmt.Errorf(
					"Error reading depends_on for output %q: %s",
					n,
					err)
			}
		}

		// If we have a description field, then filter that
		var description string
		if o := listVal.Filter("description"); len(o.Items) > 0 {
			err := hcl.DecodeObject(&description, o.Items[0].Val)
			if err != nil {
				return nil, fmt.Errorf(
					"Error reading description for output %q: %s",
					n,
					err)
			}
		}

		result = append(result, &Output{
			Name:        n,
			RawConfig:   rawConfig,
			DependsOn:   dependsOn,
			Description: description,
		})
	}

	return result, nil
}
1133170
func (c *stringChanger) List() ([]string, error) {
	if c.err != nil {
		return nil, c.err
	}
	var list []string
	err := c.node.doChildren(func(cn *node) error {
		list = append(list, cn.content.value().(string))
		return nil
	})
	if err != nil {
		return nil, err
	}
	return list, nil
}
159099
func tableOutput(list []string, c *columnize.Config) string {
	if len(list) == 0 {
		return ""
	}

	delim := "|"
	if c != nil && c.Delim != "" {
		delim = c.Delim
	}

	underline := ""
	headers := strings.Split(list[0], delim)
	for i, h := range headers {
		h = strings.TrimSpace(h)
		u := strings.Repeat("-", len(h))

		underline = underline + u
		if i != len(headers)-1 {
			underline = underline + delim
		}
	}

	list = append(list, "")
	copy(list[2:], list[1:])
	list[1] = underline

	return columnOutput(list, c)
}
164939
func output(stack *cloudformation.Stack, key string) (output *cloudformation.Output) {
	for _, o := range stack.Outputs {
		if *o.OutputKey == key {
			output = o
		}
	}
	return
}
963632
func (c *Client) VolumeList() ([]*ct.Volume, error) {
	var volumes []*ct.Volume
	return volumes, c.Get("/volumes", &volumes)
}
394169
func (c *CmdSimpleFSList) writeListingsToBuffer(outputBuffer *bytes.Buffer,
	listings []Listing,
	terminalWidth int) {

	if len(listings) == 0 {
		return
	}

	if c.options.long {
		var (
			widthPermissions  int
			widthNumHardLinks int
			widthOwner        int
			widthGroup        int
			widthSize         int
			widthTime         int
		)
		// check max widths for each field
		for _, l := range listings {
			if len(l.permissions) > widthPermissions {
				widthPermissions = len(l.permissions)
			}
			if len(l.numHardLinks) > widthNumHardLinks {
				widthNumHardLinks = len(l.numHardLinks)
			}
			if len(l.owner) > widthOwner {
				widthOwner = len(l.owner)
			}
			if len(l.group) > widthGroup {
				widthGroup = len(l.group)
			}
			if len(l.size) > widthSize {
				widthSize = len(l.size)
			}
			if len(l.time) > widthTime {
				widthTime = len(l.time)
			}
		}

		// now print the listings
		for _, l := range listings {
			// permissions
			outputBuffer.WriteString(l.permissions)
			for i := 0; i < widthPermissions-len(l.permissions); i++ {
				outputBuffer.WriteString(" ")
			}
			outputBuffer.WriteString(" ")

			// number of hard links (right justified)
			for i := 0; i < widthNumHardLinks-len(l.numHardLinks); i++ {
				outputBuffer.WriteString(" ")
			}
			for i := 0; i < 2-widthNumHardLinks; i++ {
				outputBuffer.WriteString(" ")
			}
			outputBuffer.WriteString(l.numHardLinks)
			outputBuffer.WriteString(" ")

			// owner
			outputBuffer.WriteString(l.owner)
			for i := 0; i < widthOwner-len(l.owner); i++ {
				outputBuffer.WriteString(" ")
			}
			outputBuffer.WriteString(" ")

			// group
			outputBuffer.WriteString(l.group)
			for i := 0; i < widthGroup-len(l.group); i++ {
				outputBuffer.WriteString(" ")
			}
			outputBuffer.WriteString(" ")

			// size
			for i := 0; i < widthSize-len(l.size); i++ {
				outputBuffer.WriteString(" ")
			}
			outputBuffer.WriteString(l.size)
			outputBuffer.WriteString(" ")

			// month
			outputBuffer.WriteString(l.month)
			outputBuffer.WriteString(" ")

			// day
			outputBuffer.WriteString(l.day)
			outputBuffer.WriteString(" ")

			// time
			for i := 0; i < widthTime-len(l.time); i++ {
				outputBuffer.WriteString(" ")
			}
			outputBuffer.WriteString(l.time)
			outputBuffer.WriteString(" ")

			// name
			c.writeListingName(outputBuffer, l)
			outputBuffer.WriteString("\n")
		}
	} else if c.options.one {
		separator := "\n"

		for _, l := range listings {
			c.writeListingName(outputBuffer, l)
			outputBuffer.WriteString(separator)
		}
	} else {
		separator := "  "

		// calculate the number of rows needed for column output
		numRows := 1
		var colWidths []int
		for {
			numColsFloat := float64(len(listings)) / float64(numRows)
			numColsFloat = math.Ceil(numColsFloat)
			numCols := int(numColsFloat)

			colWidths = make([]int, numCols)
			for i := range colWidths {
				colWidths[i] = 0
			}

			colListings := make([]int, numCols)
			for i := 0; i < len(colListings); i++ {
				colListings[i] = 0
			}

			// calculate necessary column widths
			// also calculate the number of listings per column
			for i := 0; i < len(listings); i++ {
				col := i / numRows
				if colWidths[col] < len(listings[i].name) {
					colWidths[col] = len(listings[i].name)
				}
				colListings[col]++
			}

			// calculate the maximum width of each row
			maxRowLength := 0
			for i := 0; i < numCols; i++ {
				maxRowLength += colWidths[i]
			}
			maxRowLength += len(separator) * (numCols - 1)

			if maxRowLength > terminalWidth && numRows >= len(listings) {
				break
			} else if maxRowLength > terminalWidth {
				numRows++
			} else {
				listingsInFirstCol := colListings[0]
				listingsInLastCol := colListings[len(colListings)-1]

				// prevent short last (right-hand) columns
				if listingsInLastCol <= listingsInFirstCol/2 &&
					listingsInFirstCol-listingsInLastCol >= 5 {
					numRows++
				} else {
					break
				}
			}
		}

		for r := 0; r < numRows; r++ {
			for i, l := range listings {
				if i%numRows == r {
					c.writeListingName(outputBuffer, l)
					for s := 0; s < colWidths[i/numRows]-len(l.name); s++ {
						outputBuffer.WriteString(" ")
					}
					outputBuffer.WriteString(separator)
				}
			}
			if len(listings) > 0 {
				outputBuffer.Truncate(outputBuffer.Len() - len(separator))
			}
			outputBuffer.WriteString("\n")
		}
	}
}
1179366
func (p *printer) singleLineList(l *ast.ListType) []byte {
	buf := &bytes.Buffer{}

	buf.WriteString("[")
	for i, item := range l.List {
		if i != 0 {
			buf.WriteString(", ")
		}

		// Output the item itself
		buf.Write(p.output(item))

		// The heredoc marker needs to be at the end of line.
		if lit, ok := item.(*ast.LiteralType); ok && lit.Token.Type == token.HEREDOC {
			buf.WriteByte(newline)
		}
	}

	buf.WriteString("]")
	return buf.Bytes()
}
1006046
func generateListFilesystemsOutput(ctx *cmd.Context, api StorageListAPI, ids []string) (map[string]FilesystemInfo, error) {

	results, err := api.ListFilesystems(ids)
	if err != nil {
		return nil, errors.Trace(err)
	}

	// filter out valid output, if any
	var valid []params.FilesystemDetails
	for _, result := range results {
		if result.Error == nil {
			valid = append(valid, result.Result...)
			continue
		}
		// display individual error
		fmt.Fprintf(ctx.Stderr, "%v\n", result.Error)
	}
	if len(valid) == 0 {
		return nil, nil
	}
	return convertToFilesystemInfo(valid)
}
198429
func generateListStorageOutput(ctx *cmd.Context, api StorageListAPI) (map[string]StorageInfo, error) {
	results, err := api.ListStorageDetails()
	if err != nil {
		return nil, errors.Trace(err)
	}
	if len(results) == 0 {
		return nil, nil
	}
	return formatStorageDetails(results)
}