<commit_before>package commander

import (
	"github.com/WindomZ/testify/assert"
	"testing"
)

func TestCommand_CommandsString(t *testing.T) {
	c := newCommand(true)

	c.Command("test").
		Version("0.0.1").
		Description("this is a test cli.")

	c.Command("add <x> <y>").
		Description("this addition operation")

	c.Command("sub <x> <y>").
		Description("this subtraction operation").
		Command("again").
		Description("this subtraction operation again")

	assert.Equal(t, c.CommandsString(""),
		[]string{
			"add           this addition operation",
			"sub           this subtraction operation",
			"sub again     this subtraction operation again",
		})
}

func TestCommand_HelpMessage(t *testing.T) {
	c := newCommand(true)

	c.Usage("cmd <x>", "this is description").
		Option("-c, --config", "config description").
		Option("-d, --drop", "drop description")

	c.Command("cmd2").
		Option("-a, --about", "cmd2 about description").
		Option("-t, --test", "cmd2 test description")

	c.Command("cmd3 [y]").
		Option("-b=<kn>, --bold=<kn>", "cmd3 bold description").
		Option("-c, --count", "cmd3 count description")

	assert.Equal(t, c.UsagesString(),
		[]string{
			"cmd <x> [[-c|--config] | [-d|--drop]]",
			"cmd cmd2 [[-a|--about] | [-t|--test]]",
			"cmd cmd3 [y] [[-b=<kn>|--bold=<kn>] | [-c|--count]]",
		})
	assert.Equal(t, c.OptionsString(),
		[]string{
			"-c --config   config description",
			"-d --drop     drop description",
			"-a --about    cmd2 about description",
			"-t --test     cmd2 test description",
			"-b=<kn> --bold=<kn>\n              cmd3 bold description",
			"-c --count    cmd3 count description",
		})

	assert.Equal(t, c.HelpMessage(),
		`  this is description

  Usage:
    cmd <x> [[-c|--config] | [-d|--drop]]
    cmd cmd2 [[-a|--about] | [-t|--test]]
    cmd cmd3 [y] [[-b=<kn>|--bold=<kn>] | [-c|--count]]

  Options:
    -c --config   config description
    -d --drop     drop description
    -a --about    cmd2 about description
    -t --test     cmd2 test description
    -b=<kn> --bold=<kn>
                  cmd3 bold description
    -c --count    cmd3 count description
`)
}

func TestCommand_Aliases(t *testing.T) {
	c := newCommand(true)
	c.Command("cmd").
		Aliases([]string{"c0", "cmd0"}).<commit_msg>test: enhanced command<commit_after>package commander

import (
	"github.com/WindomZ/testify/assert"
	"testing"
)

func TestCommand_CommandsString(t *testing.T) {
	c := newCommand(true)

	c.Command("test").
		Version("0.0.1").
		Description("this is a test cli.")

	c.Command("add <x> <y>").
		Description("this addition operation")

	c.Command("sub <x> <y>").
		Description("this subtraction operation").
		Command("again").
		Description("this subtraction operation again")

	assert.Equal(t, c.CommandsString(""),
		[]string{
			"add           this addition operation",
			"sub           this subtraction operation",
			"sub again     this subtraction operation again",
		})
}

func TestCommand_HelpMessage(t *testing.T) {
	c := newCommand(true)
	assert.Equal(t, c.HelpMessage(), "")

	c.Usage("cmd <x>", "this is description").
		Option("-c, --config", "config description").
		Option("-d, --drop", "drop description")

	c.Command("cmd2").
		Option("-a, --about", "cmd2 about description").
		Option("-t, --test", "cmd2 test description")

	c.Command("cmd3 [y]").
		Option("-b=<kn>, --bold=<kn>", "cmd3 bold description").
		Option("-c, --count", "cmd3 count description")

	assert.Equal(t, c.UsagesString(),
		[]string{
			"cmd <x> [[-c|--config] | [-d|--drop]]",
			"cmd cmd2 [[-a|--about] | [-t|--test]]",
			"cmd cmd3 [y] [[-b=<kn>|--bold=<kn>] | [-c|--count]]",
		})
	assert.Equal(t, c.OptionsString(),
		[]string{
			"-c --config   config description",
			"-d --drop     drop description",
			"-a --about    cmd2 about description",
			"-t --test     cmd2 test description",
			"-b=<kn> --bold=<kn>\n              cmd3 bold description",
			"-c --count    cmd3 count description",
		})

	assert.Equal(t, c.HelpMessage(),
		`  this is description

  Usage:
    cmd <x> [[-c|--config] | [-d|--drop]]
    cmd cmd2 [[-a|--about] | [-t|--test]]
    cmd cmd3 [y] [[-b=<kn>|--bold=<kn>] | [-c|--count]]

  Options:
    -c --config   config description
    -d --drop     drop description
    -a --about    cmd2 about description
    -t --test     cmd2 test description
    -b=<kn> --bold=<kn>
                  cmd3 bold description
    -c --count    cmd3 count description
`)

	c.Annotation("Example", []string{
		"cmd xxx -c",
		"cmd cmd2 -a",
		"cmd cmd3 y -b",
	})
	assert.Equal(t, c.HelpMessage(),
		`  this is description

  Usage:
    cmd <x> [[-c|--config] | [-d|--drop]]
    cmd cmd2 [[-a|--about] | [-t|--test]]
    cmd cmd3 [y] [[-b=<kn>|--bold=<kn>] | [-c|--count]]

  Options:
    -c --config   config description
    -d --drop     drop description
    -a --about    cmd2 about description
    -t --test     cmd2 test description
    -b=<kn> --bold=<kn>
                  cmd3 bold description
    -c --count    cmd3 count description

  Example:
    cmd xxx -c
    cmd cmd2 -a
    cmd cmd3 y -b
`)

	c.Doc(`  Usage:
    cmd <x> [[-c|--config] | [-d|--drop]]
    cmd cmd2 [[-a|--about] | [-t|--test]]
    cmd cmd3 [y] [[-b=<kn>|--bold=<kn>] | [-c|--count]]
`)

	assert.Equal(t, c.HelpMessage(), `  Usage:
    cmd <x> [[-c|--config] | [-d|--drop]]
    cmd cmd2 [[-a|--about] | [-t|--test]]
    cmd cmd3 [y] [[-b=<kn>|--bold=<kn>] | [-c|--count]]
`)
}

func TestCommand_Aliases(t *testing.T) {
	c := newCommand(true)
	c.Command("cmd").
		Aliases([]string{"c0", "cmd0"}).
{'fraction_non_alphanumeric': 0.21272365805168986, 'fraction_numerical': 0.010844026748599312, 'mean_word_length': 2.679521276595745, 'pattern_counts': {'":': 0, '<': 48, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4689942', 'n_tokens_mistral': 2124, 'n_tokens_neox': 1970, 'n_words': 495}