You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: listoperations.go
    path of file: ./repos/juju/cmd/juju/action
    
    the code of the file until where you have to start completion: // Copyright 2019 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package action

import (
	"fmt"
	"io"
	"reflect"
	"sort"
	"strconv"
	"strings"
	"time"

	"github.com/juju/cmd/v3"
	"github.com/juju/errors"
	"github.com/juju/gnuflag"
	"github.com/juju/names/v5"

	actionapi "github.com/juju/juju/api/client/action"
	jujucmd "github.com/juju/juju/cmd"
	"github.com/juju/juju/cmd/modelcmd"
	"github.co
    
func (c *listOperationsCommand) Run(ctx *cmd.Context) error {
	api, err := c.NewActionAPIClient()
	if err != nil {
		return err
	}
	defer api.Close()

	args := actionapi.OperationQueryArgs{
		Applications: c.applicationNames,
		Units:        c.unitNames,
		Machines:     c.machineNames,
		ActionNames:  c.actionNames,
		Status:       c.statusValues,
	}
	if c.offset != 0 {
		offset := int(c.offset)
		args.Offset = &offset
	}
	if c.limit != 0 {
		limit := int(c.limit)
		args.Limit = &limit
	}
	results, err := api.ListOperations(args)
	if err != nil {
		return errors.Trace(err)
	}

	out := make(map[string]interface{})
	var operationResults byId = results.Operations
	if len(operationResults) == 0 {
		ctx.Infof("no matching operations")
		return nil
	}

	sort.Sort(operationResults)
	if c.out.Name() == "plain" {
		if c.offset > 0 || results.Truncated {
			fmt.Fprintf(ctx.Stdout, "Displaying operation results %d to %d.\n", c.offset+1, int(c.offset)+len(operationResults))
			if results.Truncated {
				limit := c.limit
				if limit == 0 {
					limit = defaultMaxOperationsLimit
				}
				fmt.Fprintf(ctx.Stdout, "Run the command again with --offset=%d --limit=%d to see the next batch.\n\n", c.offset+limit, limit)
			}
		}
		return c.out.Write(ctx, operationResults)
	}
	for _, result := range operationResults {
		out[result.ID] = formatOperationResult(result, c.utc)
	}
	return c.out.Write(ctx, out)
}