<commit_before>package cmd

import (
	"fmt"

	"github.com/spf13/cobra"
)

// runCmd represents the run command
var runCmd = &cobra.Command{
	Use:   "run",
	Short: "Run relay",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("Hello!")
	},
}

func init() {
	rootCmd.AddCommand(runCmd)
}<commit_msg>basic command to launch router<commit_after>package cmd

import (
	"fmt"

	"github.com/mmcloughlin/pearl"
	"github.com/mmcloughlin/pearl/log"
	"github.com/mmcloughlin/pearl/torconfig"
	"github.com/spf13/cobra"
)

// runCmd represents the run command
var runCmd = &cobra.Command{
	Use:   "run",
	Short: "Run relay",
	RunE: func(cmd *cobra.Command, args []string) error {
		return run()
	},
}

func init() {
	rootCmd.AddCommand(runCmd)
}

func run() error {
	platform := torconfig.NewPlatformHostOS("pearl", "0.1")
	config := &torconfig.Config{
		Nickname: "pearl",
		ORPort:   9001,
		Platform: platform.String(),
	}

	logger := log.NewDebug()

	r, err := pearl.NewRouter(config, logger)
	if err != nil {
		return err
	}

	desc := r.Descriptor()
	doc, err := desc.Document()
	if err != nil {
		return err
	}

	fmt.Println(string(doc.Encode()))

	go func() {
		r.Run()
	}()

	authority := "127.0.0.1:7000"
	err = desc.PublishToAuthority(authority)
	if err != nil {
		return err
	}
	logger.With("authority", authority).Info("published descriptor")

	select {}
}
{'fraction_non_alphanumeric': 0.16374269005847952, 'fraction_numerical': 0.014619883040935672, 'mean_word_length': 3.9422382671480145, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '7278939', 'n_tokens_mistral': 565, 'n_tokens_neox': 536, 'n_words': 115}