<commit_before>package main

import (
	"os"

	"fmt"
	"log"

	flag "github.com/spf13/pflag"

	"kubevirt.io/kubevirt/pkg/virtctl"
	"kubevirt.io/kubevirt/pkg/virtctl/console"
	"kubevirt.io/kubevirt/pkg/virtctl/convert"
	"kubevirt.io/kubevirt/pkg/virtctl/spice"
)

func main() {

	log.SetFlags(0)
	log.SetOutput(os.Stderr)

	registry := map[string]virtctl.App{
		"console":      &console.Console{},
		"options":      &virtctl.Options{},
		"spice":        &spice.Spice{},
		"convert-spec": convert.NewConvertCommand(),
	}

	for cmd, app := range registry {
		f := app.FlagSet()
		f.Bool("help", false, "Print usage.")
		f.MarkHidden("help")
		f.Usage = func() {
			fmt.Fprint(os.Stderr, app.Usage())
		}

		if os.Args[1] != cmd {
			continue
		}
		flags, err := Parse(f)

		h, _ := flags.GetBool("help")
		if h || err != nil {
			f.Usage()
			return
		}
		os.Exit(app.Run(flags))
	}

	Usage()
	os.Exit(1)
}

func Parse(flags *flag.FlagSet) (*flag.FlagSet, error) {
	flags.AddFlagSet((&virtctl.Options{}).FlagSet())
	err := flags.Parse(os.Args[1:])
	return flags, err
}

func Usage() {
	fmt.Fprintln(os.Stderr,
		`virtctl controls VM related operations on your kubernetes cluster.

Basic Commands:
  console        Connect to a serial console on a VM
  convert-spec   Convert between Libvirt and KubeVirt specifications

Use "virtctl <command> --help" for more information about a given command.
Use "virtctl options" for a list of global command-line options (applies to all commands).
	`)<commit_msg>Don't look for virtctl command if none is given<commit_after>package main

import (
	"os"

	"fmt"
	"log"

	flag "github.com/spf13/pflag"

	"kubevirt.io/kubevirt/pkg/virtctl"
	"kubevirt.io/kubevirt/pkg/virtctl/console"
	"kubevirt.io/kubevirt/pkg/virtctl/convert"
	"kubevirt.io/kubevirt/pkg/virtctl/spice"
)

func main() {

	log.SetFlags(0)
	log.SetOutput(os.Stderr)

	registry := map[string]virtctl.App{
		"console":      &console.Console{},
		"options":      &virtctl.Options{},
		"spice":        &spice.Spice{},
		"convert-spec": convert.NewConvertCommand(),
	}

	if len(os.Args) > 1 {
		for cmd, app := range registry {
			f := app.FlagSet()
			f.Bool("help", false, "Print usage.")
			f.MarkHidden("help")
			f.Usage = func() {
				fmt.Fprint(os.Stderr, app.Usage())
			}

			if os.Args[1] != cmd {
				continue
			}
			flags, err := Parse(f)

			h, _ := flags.GetBool("help")
			if h || err != nil {
				f.Usage()
				return
			}
			os.Exit(app.Run(flags))
		}
	}

	Usage()
	os.Exit(1)
}

func Parse(flags *flag.FlagSet) (*flag.FlagSet, error) {
	flags.AddFlagSet((&virtctl.Options{}).FlagSet())
	err := flags.Parse(os.Args[1:])
	return flags, err
}

func Usage() {
	fmt.Fprintln(os.Stderr,
		`virtctl controls VM related operations on your kubernetes cluster.

Basic Commands:
  console        Connect to a serial console on a VM
  convert-spec   Convert between Libvirt and KubeVirt specifications

Use "virtctl <command> --help" for more information about a given command.
Use "virtctl options" for a list of global command-line options (applies to all commands).
	`)
{'fraction_non_alphanumeric': 0.1527687296416938, 'fraction_numerical': 0.004234527687296417, 'mean_word_length': 3.4636627906976742, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 6, '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': '7282429', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1149, 'n_words': 263}