<commit_before>// Hap - the simple and effective provisioner
// Copyright (c) 2017 GWoo (https://github.com/gwoo)
// The BSD License http://opensource.org/licenses/bsd-license.php.

package main

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

	"github.com/gwoo/hap"
	"github.com/gwoo/hap/cmd/hap/cli"
	flag "github.com/ogier/pflag"
)

var host = flag.StringP("host", "h", "", "Host to use for commands. Use glob patterns to match multiple hosts. Use --host=* for all hosts.")
var hapfile = flag.StringP("file", "f", "Hapfile", "Location of a Hapfile.")
var help = flag.BoolP("help", "", false, "Show help")
var verbose = flag.BoolP("verbose", "v", false, "[deprecated] Verbose mode is always on")

var logger VerboseLogger

// Version is just the version of hap
var Version string

func main() {
	flag.Usage = Usage
	flag.Parse()

	if err := new(hap.Git).Exists(); err != nil {
		fmt.Println(err)
		os.Exit(2)
	}
	var command cli.Command
	if cmd := flag.Arg(0); cmd != "" {
		command = cli.Commands.Get(cmd)
		if command == nil {
			fmt.Printf("Command `%s` not found.\n", cmd)
		}
	}
	if len(os.Args) <= 1 || *help || command == nil {
		flag.Usage()
		return
	}
	if !command.IsRemote() {
		run(nil, command)
		return
	}
	if _, ok := command.(*cli.DeployCmd); !ok && *host == "" {
		fmt.Println("Missing host Please specify -h or --host=")
		os.Exit(2)
	}
	hf, err := hap.NewHapfile(*hapfile)
	if err != nil {
		fmt.Println(err)
		os.Exit(2)
	}
	deploy := flag.Arg(1)
	var hosts = make(map[string]*hap.Host, 0)
	if c, ok := hf.Deploys[deploy]; ok {
		for _, n := range c.Host {
			hosts[n] = hf.Host(n)
		}
	} else if *host != "" {
		hosts = hf.GetHosts(*host)
	}
	if len(hosts) == 0 {
		fmt.Printf("No hosts found for `%s`\n", *host)
		return
	}
	var wg sync.WaitGroup
	for _, h := range hosts {
		wg.Add(1)
		go func(h *hap.Host) {
			defer wg.Done()
			run(h, command)<commit_msg>limit deploy by specifying the host<commit_after>// Hap - the simple and effective provisioner
// Copyright (c) 2017 GWoo (https://github.com/gwoo)
// The BSD License http://opensource.org/licenses/bsd-license.php.

package main

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

	"github.com/gwoo/hap"
	"github.com/gwoo/hap/cmd/hap/cli"
	flag "github.com/ogier/pflag"
)

var host = flag.StringP("host", "h", "", "Host to use for commands. Use glob patterns to match multiple hosts. Use --host=* for all hosts.")
var hapfile = flag.StringP("file", "f", "Hapfile", "Location of a Hapfile.")
var help = flag.BoolP("help", "", false, "Show help")
var verbose = flag.BoolP("verbose", "v", false, "[deprecated] Verbose mode is always on")

var logger VerboseLogger

// Version is just the version of hap
var Version string

func main() {
	flag.Usage = Usage
	flag.Parse()

	if err := new(hap.Git).Exists(); err != nil {
		fmt.Println(err)
		os.Exit(2)
	}
	var command cli.Command
	if cmd := flag.Arg(0); cmd != "" {
		command = cli.Commands.Get(cmd)
		if command == nil {
			fmt.Printf("Command `%s` not found.\n", cmd)
		}
	}
	if len(os.Args) <= 1 || *help || command == nil {
		flag.Usage()
		return
	}
	if !command.IsRemote() {
		run(nil, command)
		return
	}
	if _, ok := command.(*cli.DeployCmd); !ok && *host == "" {
		fmt.Println("Missing host Please specify -h or --host=")
		os.Exit(2)
	}
	hf, err := hap.NewHapfile(*hapfile)
	if err != nil {
		fmt.Println(err)
		os.Exit(2)
	}
	deploy := flag.Arg(1)
	var hosts = make(map[string]*hap.Host, 0)
	if c, ok := hf.Deploys[deploy]; ok {
		for _, n := range c.Host {
			if *host == "" || *host == n {
				hosts[n] = hf.Host(n)
			}
		}
	} else if *host != "" {
		hosts = hf.GetHosts(*host)
	}
	if len(hosts) == 0 {
		fmt.Printf("No hosts found for `%s`\n", *host)
		return
	}
	var wg sync.WaitGroup
	for _, h := range hosts {
		wg.Add(1)
		go func(h *hap.Host) {
			defer wg.Done()
			run(h, command)
{'fraction_non_alphanumeric': 0.1813929313929314, 'fraction_numerical': 0.006756756756756757, 'mean_word_length': 3.262458471760797, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6367612', 'n_tokens_mistral': 1616, 'n_tokens_neox': 1526, 'n_words': 404}