// Copyright 2022 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0

package xflags

import (
	"flag"
	"github.com/stretchr/testify/assert"
	"testing"
)

type testStructParseCommand1 struct {
	V1   bool `short:"v1"`
	Cmd1 struct {
		V2 bool `short:"v2"`
		V4 int  `short:"v4"`
	} `command:"cmd1"`
	Cmd2 struct {
		V3   bool `short:"v3"`
		Cmd3 struct {
			V3 bool `short:"v3"`
		} `command:"cmd3"`
	} `command:"cmd2"`
}

func TestParse(t *testing.T) {
	tests := []struct {
		commandline []string
	}{
		{[]string{"command1"}},
	}
	for _, test := range tests {
		t.Run(test.commandline[0], func(t *testing.T) {

			c := &cmd[testStructParseCommand1]{}
			c.settings = &Settings[testStructParseCommand1]{}

			c.commands = []*cmd[testStructParseCommand1]{}

			c.commands = append(c.commands, &cmd[testStructParseCommand1]{
				name:    "command1",
				flagSet: &flag.FlagSet{},
			})

			c.parse(test.commandline)
			assert.Equal(t, 0, len(c.settings.errors))

		})
	}
}