<commit_before>package util

import (
	"flag"
	"net/url"
	"time"

	"github.com/prometheus/common/model"
)

// Registerer is a thing that can RegisterFlags
type Registerer interface {
	RegisterFlags(*flag.FlagSet)
}

// RegisterFlags registers flags with the provided Registerers
func RegisterFlags(rs ...Registerer) {
	for _, r := range rs {
		r.RegisterFlags(flag.CommandLine)
	}
}

// TimeValue is a time.Time that can be used as a flag.
type TimeValue struct {
	time.Time
}

// String implements flag.Value
func (v TimeValue) String() string {
	return v.Time.Format(time.RFC3339)
}

// Set implements flag.Value
func (v *TimeValue) Set(s string) error {
	var err error
	v.Time, err = time.Parse(time.RFC3339, s)
	return err
}

// DayValue is a model.Time that can be used as a flag.
// NB it only parses days!
type DayValue struct {
	model.Time
}

// String implements flag.Value
func (v DayValue) String() string {
	return v.Time.Time().Format(time.RFC3339)
}

// Set implements flag.Value
func (v *DayValue) Set(s string) error {
	t, err := time.Parse("2006-01-02", s)
	if err != nil {
		return err
	}
	v.Time = model.TimeFromUnix(t.Unix())
	return nil
}

// URLValue is a url.URL that can be used as a flag.
type URLValue struct {
	*url.URL
}

// String implements flag.Value
func (v URLValue) String() string {
	return v.URL.String()<commit_msg>Deal with nil URL for url flags.<commit_after>package util

import (
	"flag"
	"net/url"
	"time"

	"github.com/prometheus/common/model"
)

// Registerer is a thing that can RegisterFlags
type Registerer interface {
	RegisterFlags(*flag.FlagSet)
}

// RegisterFlags registers flags with the provided Registerers
func RegisterFlags(rs ...Registerer) {
	for _, r := range rs {
		r.RegisterFlags(flag.CommandLine)
	}
}

// TimeValue is a time.Time that can be used as a flag.
type TimeValue struct {
	time.Time
}

// String implements flag.Value
func (v TimeValue) String() string {
	return v.Time.Format(time.RFC3339)
}

// Set implements flag.Value
func (v *TimeValue) Set(s string) error {
	var err error
	v.Time, err = time.Parse(time.RFC3339, s)
	return err
}

// DayValue is a model.Time that can be used as a flag.
// NB it only parses days!
type DayValue struct {
	model.Time
}

// String implements flag.Value
func (v DayValue) String() string {
	return v.Time.Time().Format(time.RFC3339)
}

// Set implements flag.Value
func (v *DayValue) Set(s string) error {
	t, err := time.Parse("2006-01-02", s)
	if err != nil {
		return err
	}
	v.Time = model.TimeFromUnix(t.Unix())
	return nil
}

// URLValue is a url.URL that can be used as a flag.
type URLValue struct {
	*url.URL
}

// String implements flag.Value
func (v URLValue) String() string {
	if v.URL == nil {
		return ""
	}
	return v.URL.String()
{'fraction_non_alphanumeric': 0.1211461733768589, 'fraction_numerical': 0.014508523757707652, 'mean_word_length': 3.499184339314845, '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': '7410023', 'n_tokens_mistral': 991, 'n_tokens_neox': 967, 'n_words': 315}