package command

import (
	
	

	
)

type FlagSet map[string]Flag

type Extended struct {
	Description string `yaml:"description,omitempty" json:"description,omitempty" jsonschema_description:"Description of the flag"`
	Nargs       int    `yaml:"nargs,omitempty" json:"nargs,omitempty" jsonschema_description:"Amount of arguments consumed"`
	Default     string `yaml:"default,omitempty" json:"default,omitempty" jsonschema_description:"Default value of the flag"`
}

func ( FlagSet) () (any, error) {
	 := make(map[string]any)

	for ,  := range  {
		switch {
		case .Nargs != 0 || .Default != "":
			[.format()] = Extended{
				Description: .Description,
				Nargs:       .Nargs,
				Default:     .Default,
			}
		default:
			[.format()] = .Description
		}
	}
	return , nil
}

func ( *FlagSet) ( *yaml.Node) error {
	 := make(map[string]any)
	if  := .Decode(&);  != nil {
		return 
	}

	 := make(FlagSet)
	for ,  := range  {
		switch v := .(type) {
		case string:
			,  := parseFlag(, )
			if  != nil {
				return 
			}
			[.Name()] = * // TODO ref?

		case map[string]any:
			,  := parseFlag(, "")
			if  != nil {
				return 
			}
			.Description, _ = ["description"].(string)
			.Nargs, _ = ["nargs"].(int)
			switch d := ["default"].(type) {
			case string:
				.Default = 
			case int:
				.Default = fmt.Sprint()
			case bool:
				.Default = fmt.Sprint()
			case nil:
			default:
				.Default = fmt.Sprint()
			}

			[.Name()] = * // TODO ref?

		default:
			return errors.New("invalid type for FlagSet")
		}
	}
	* = 
	return nil
}