<commit_before>package main

import (
	"fmt"
	"github.com/jessevdk/go-flags"
	"github.com/martinp/nadapi/api"
	"github.com/martinp/nadapi/nad"
	"log"
	"os"
)

func main() {
	var opts struct {
		Device       string `short:"d" long:"device" description:"Path to serial device" value-name:"FILE" required:"true"`
		EnableVolume bool   `short:"x" long:"volume" description:"Allow volume adjustment. Use with caution!"`
	}

	var server struct {
		Listen string `short:"l" long:"listen" description:"Listen address" value-name:"ADDR" default:":8080"`
	}

	var cli struct {
		Command string `short:"c" long:"command" description:"Command to send" required:"true"`
	}

	p := flags.NewParser(&opts, flags.Default)
	if _, err := p.AddCommand("server", "Start API server",
		"REST API for NAD amplifier.", &server); err != nil {
		log.Fatal(err)
	}
	if _, err := p.AddCommand("cli", "Send command",
		"Send command to NAD amplifier.", &cli); err != nil {
		log.Fatal(err)
	}

	if _, err := p.Parse(); err != nil {
		os.Exit(1)
	}

	nad, err := nad.New(opts.Device)
	if err != nil {
		log.Fatal(err)
	}
	nad.EnableVolume = opts.EnableVolume

	switch p.Active.Name {
	case "server":
		api := api.New(nad)
		log.Printf("Listening on %s", server.Listen)
		if err := api.ListenAndServe(server.Listen); err != nil {
			log.Fatal(err)
		}
	case "cli":
		reply, err := nad.SendString(cli.Command)
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println(reply)
	default:
		log.Fatal("unknown subcommand")
	}
}<commit_msg>Use positional arg for command<commit_after>package main

import (
	"fmt"
	"github.com/jessevdk/go-flags"
	"github.com/martinp/nadapi/api"
	"github.com/martinp/nadapi/nad"
	"log"
	"os"
)

func main() {
	var opts struct {
		Device       string `short:"d" long:"device" description:"Path to serial device" value-name:"FILE" required:"true"`
		EnableVolume bool   `short:"x" long:"volume" description:"Allow volume adjustment. Use with caution!"`
	}

	var server struct {
		Listen string `short:"l" long:"listen" description:"Listen address" value-name:"ADDR" default:":8080"`
	}

	var send = struct {
		Args struct {
			Command string `positional-arg-name:"<command>" description:"Command to send"`
		} `positional-args:"yes" required:"yes"`
	}{}

	p := flags.NewParser(&opts, flags.Default)
	if _, err := p.AddCommand("server", "Start API server",
		"REST API for NAD amplifier.", &server); err != nil {
		log.Fatal(err)
	}
	if _, err := p.AddCommand("send", "Send command",
		"Send command to NAD amplifier.", &send); err != nil {
		log.Fatal(err)
	}

	if _, err := p.Parse(); err != nil {
		os.Exit(1)
	}

	nad, err := nad.New(opts.Device)
	if err != nil {
		log.Fatal(err)
	}
	nad.EnableVolume = opts.EnableVolume

	switch p.Active.Name {
	case "server":
		api := api.New(nad)
		log.Printf("Listening on %s", server.Listen)
		if err := api.ListenAndServe(server.Listen); err != nil {
			log.Fatal(err)
		}
	case "send":
		reply, err := nad.SendString(send.Args.Command)
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println(reply)
	default:
		log.Fatal("unknown subcommand")
	}
}
{'fraction_non_alphanumeric': 0.16785714285714284, 'fraction_numerical': 0.003246753246753247, 'mean_word_length': 3.9138755980861246, 'pattern_counts': {'":': 6, '<': 4, '<?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': '5019031', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1092, 'n_words': 270}