<commit_before>package main

import (
	"github.com/jessevdk/go-flags"
	"log"
	"os"
	"time"
)

type Options struct {
	Verbose			bool	`long:"verbose" short:"v"`

	Interface		string	`long:"interface" short:"i" value-name:"IFACE" description:"Use address from interface"`
	InterfaceFamily	Family	`long:"interface-family"`

	Server		string	`long:"server" value-name:"HOST[:PORT]"`
	Timeout		time.Duration `long:"timeout" value-name:"DURATION" default:"10s"`
	TSIGName	string	`long:"tsig-name"`
	TSIGSecret	string	`long:"tsig-secret" env:"TSIG_SECRET"`
	TSIGAlgorithm TSIGAlgorithm `long:"tsig-algorithm" default:"hmac-sha1."`

	Zone		string	`long:"zone" description:"Zone to update"`
	Name		string	`long:"name" description:"Name to update"`
	TTL			int		`long:"ttl" default:"60"`
}

func main() {
	var options Options

	if args, err := flags.Parse(&options); err != nil {
		log.Fatalf("flags.Parse: %v", err)
		os.Exit(1)
	} else if len(args) > 0 {
		log.Fatalf("Usage: no args")
		os.Exit(1)
	}

	var update = Update{
		ttl:	 options.TTL,
		timeout: options.Timeout,
	}

	if err := update.Init(options.Name, options.Zone, options.Server); err != nil {
		log.Fatalf("init: %v", err)
	}

	if options.TSIGName != "" {
		log.Printf("using TSIG: %v (algo=%v)", options.TSIGName, options.TSIGAlgorithm)

		update.InitTSIG(options.TSIGName, options.TSIGSecret, options.TSIGAlgorithm)
	}

	// addrs
	var addrs = new(AddrSet)

	if options.Interface == "" {

	} else if err := addrs.ScanInterface(options.Interface, options.InterfaceFamily); err != nil {
		log.Fatalf("addrs scan: %v", err)
	}

	// update
	if err := update.Update(addrs, options.Verbose); err != nil {
		log.Fatalf("update: %v", err)
	} else {
		log.Printf("update: ok")
	}
}
<commit_msg>take name as posarg, default for --tsig-name<commit_after>package main

import (
	"github.com/jessevdk/go-flags"
	"log"
	"os"
	"time"
)

type Options struct {
	Verbose			bool	`long:"verbose" short:"v"`

	Interface		string	`long:"interface" short:"i" value-name:"IFACE" description:"Use address from interface"`
	InterfaceFamily	Family	`long:"interface-family"`

	Server		string	`long:"server" value-name:"HOST[:PORT]"`
	Timeout		time.Duration `long:"timeout" value-name:"DURATION" default:"10s"`
	TSIGName	string	`long:"tsig-name"`
	TSIGSecret	string	`long:"tsig-secret" env:"TSIG_SECRET"`
	TSIGAlgorithm TSIGAlgorithm `long:"tsig-algorithm" default:"hmac-sha1."`

	Zone		string	`long:"zone" description:"Zone to update"`
	TTL			int		`long:"ttl" default:"60"`

	Args		struct {
		Name		string	`description:"DNS Name to update"`
	} `positional-args:"yes"`
}

func main() {
	var options Options

	if _, err := flags.Parse(&options); err != nil {
		log.Fatalf("flags.Parse: %v", err)
		os.Exit(1)
	}

	var update = Update{
		ttl:	 options.TTL,
		timeout: options.Timeout,
	}

	if err := update.Init(options.Args.Name, options.Zone, options.Server); err != nil {
		log.Fatalf("init: %v", err)
	}

	if options.TSIGSecret != "" {
		var name = options.TSIGName

		if name == "" {
			name = options.Args.Name
		}

		log.Printf("using TSIG: %v (algo=%v)", name, options.TSIGAlgorithm)

		update.InitTSIG(name, options.TSIGSecret, options.TSIGAlgorithm)
	}

	// addrs
	var addrs = new(AddrSet)

	if options.Interface == "" {

	} else if err := addrs.ScanInterface(options.Interface, options.InterfaceFamily); err != nil {
		log.Fatalf("addrs scan: %v", err)
	}

	// update
	if err := update.Update(addrs, options.Verbose); err != nil {
		log.Fatalf("update: %v", err)
	} else {
		log.Printf("update: ok")
	}
}

{'fraction_non_alphanumeric': 0.16530093246679853, 'fraction_numerical': 0.003955919751342187, 'mean_word_length': 4.371775417298938, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '6994343', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1310, 'n_words': 293}