<commit_before>package plalib

import (
	"errors"
	"fmt"
	// "strings"
)

func RunTargetByName(targetName string, targets []Target, stopRunning bool, params []string) error {

	target, error := FindTargetByTargetName(targetName, targets)
	if error != nil {
		err := fmt.Sprintf("Error: Invalid value: Target \"%v\" not present in Plafile.yml.\n", targetName)
		log.Errorf(err)
		// fmt.Println("Valid targets are:")
		// for tIndex := range targets {
		// fmt.Println("  -", targets[tIndex].Name)
		// }
		return errors.New(err)
	}

	// if len(params) < len(target.Parameters) {
	// missingParameters := target.Parameters[len(params):]
	// err := fmt.Sprintf("\x1b[31;2mCannot run \"%v\": Parameter \x1b[31;1m\x1b[31;4m%v\x1b[0m\x1b[31;2m not provided.\x1b[0m\n", target.Name, strings.Join(missingParameters, ", "))
	// fmt.Printf(err)
	// return errors.New(err)
	// }

	log.Infof("Running target \"%v\"", targetName)

	target.Run(params, stopRunning)
	return nil
}

func FindTargetByTargetName(targetName string, targets []Target) (Target, error) {
	for targetIndex := range targets {
		if targets[targetIndex].Name == targetName {
			return targets[targetIndex], nil
		}
	}
	return Target{}, errors.New("failed to find target")
}<commit_msg>Make target runner return basic status<commit_after>package plalib

import (
	"errors"
	"fmt"
	// "strings"
)

func RunTargetByName(targetName string, targets []Target, stopRunning bool, params []string) error {

	target, error := FindTargetByTargetName(targetName, targets)
	if error != nil {
		err := fmt.Sprintf("Error: Invalid value: Target \"%v\" not present in Plafile.yml.\n", targetName)
		log.Errorf(err)
		// fmt.Println("Valid targets are:")
		// for tIndex := range targets {
		// fmt.Println("  -", targets[tIndex].Name)
		// }
		return errors.New(err)
	}

	// if len(params) < len(target.Parameters) {
	// missingParameters := target.Parameters[len(params):]
	// err := fmt.Sprintf("\x1b[31;2mCannot run \"%v\": Parameter \x1b[31;1m\x1b[31;4m%v\x1b[0m\x1b[31;2m not provided.\x1b[0m\n", target.Name, strings.Join(missingParameters, ", "))
	// fmt.Printf(err)
	// return errors.New(err)
	// }

	log.Infof("Running target \"%v\"", targetName)

	var failure = target.Run(params, stopRunning)
	if failure {
		return errors.New(fmt.Sprintf("Error running target \"%v\"", targetName))
	}
	return nil
}

func FindTargetByTargetName(targetName string, targets []Target) (Target, error) {
	for targetIndex := range targets {
		if targets[targetIndex].Name == targetName {
			return targets[targetIndex], nil
		}
	}
	return Target{}, errors.New("Failed to find target")
}
{'fraction_non_alphanumeric': 0.16615737203972497, 'fraction_numerical': 0.015278838808250574, 'mean_word_length': 4.227544910179641, 'pattern_counts': {'":': 2, '<': 5, '<?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': '2832830', 'n_tokens_mistral': 940, 'n_tokens_neox': 899, 'n_words': 205}