<commit_before>package main

import (
	"fmt"
	"os"
	"text/tabwriter"

	"github.com/containerd/containerd"
	"github.com/containerd/containerd/api/services/execution"
	tasktypes "github.com/containerd/containerd/api/types/task"
	"github.com/urfave/cli"
)

var taskListCommand = cli.Command{
	Name:    "tasks",
	Usage:   "manage tasks",
	Aliases: []string{"t"},
	Subcommands: []cli.Command{
		{
			Name:    "list",
			Usage:   "list tasks",
			Aliases: []string{"ls"},
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "quiet, q",
					Usage: "print only the task id & pid",
				},
			},
			Action: taskListFn,
		},
	},
}

var containerListCommand = cli.Command{
	Name:    "containers",
	Usage:   "manage containers (metadata)",
	Aliases: []string{"c"},
	Subcommands: []cli.Command{
		{
			Name:    "list",
			Usage:   "list tasks",
			Aliases: []string{"ls"},
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "quiet, q",
					Usage: "print only the container id",
				},
			},
			Action: containerListFn,
		},
	},
}

func taskListFn(context *cli.Context) error {
	var (
		quiet       = context.Bool("quiet")
		ctx, cancel = appContext(context)
	)
	defer cancel()

	client, err := newClient(context)
	if err != nil {
		return err
	}
	containers, err := client.Containers(ctx)
	if err != nil {
		return err
	}

	tasks := client.TaskService()

	tasksResponse, err := tasks.List(ctx, &execution.ListRequest{})
	if err != nil {
		return err
	}

	// Join with tasks to get status.
	tasksByContainerID := map[string]*tasktypes.Task{}
	for _, task := range tasksResponse.Tasks {
		tasksByContainerID[task.ContainerID] = task
	}

	if quiet {
		for _, c := range containers {<commit_msg>[ctr] fix tasks service refernce<commit_after>package main

import (
	"fmt"
	"os"
	"text/tabwriter"

	"github.com/containerd/containerd"
	tasks "github.com/containerd/containerd/api/services/tasks/v1"
	tasktypes "github.com/containerd/containerd/api/types/task"
	"github.com/urfave/cli"
)

var taskListCommand = cli.Command{
	Name:    "tasks",
	Usage:   "manage tasks",
	Aliases: []string{"t"},
	Subcommands: []cli.Command{
		{
			Name:    "list",
			Usage:   "list tasks",
			Aliases: []string{"ls"},
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "quiet, q",
					Usage: "print only the task id & pid",
				},
			},
			Action: taskListFn,
		},
	},
}

var containerListCommand = cli.Command{
	Name:    "containers",
	Usage:   "manage containers (metadata)",
	Aliases: []string{"c"},
	Subcommands: []cli.Command{
		{
			Name:    "list",
			Usage:   "list tasks",
			Aliases: []string{"ls"},
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "quiet, q",
					Usage: "print only the container id",
				},
			},
			Action: containerListFn,
		},
	},
}

func taskListFn(context *cli.Context) error {
	var (
		quiet       = context.Bool("quiet")
		ctx, cancel = appContext(context)
	)
	defer cancel()

	client, err := newClient(context)
	if err != nil {
		return err
	}
	containers, err := client.Containers(ctx)
	if err != nil {
		return err
	}

	s := client.TaskService()

	tasksResponse, err := s.List(ctx, &tasks.ListTasksRequest{})
	if err != nil {
		return err
	}

	// Join with tasks to get status.
	tasksByContainerID := map[string]*tasktypes.Task{}
	for _, task := range tasksResponse.Tasks {
		tasksByContainerID[task.ContainerID] = task
	}

	if quiet {
		for _, c := range containers {
{'fraction_non_alphanumeric': 0.15546342907906427, 'fraction_numerical': 0.0002961208172934557, 'mean_word_length': 3.303184713375796, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6387474', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1201, 'n_words': 281}