You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: flatten.go
    path of file: ./repos/go-swagger/cmd/swagger/commands
    
    the code of the file until where you have to start completion: package commands

import (
	"errors"

	"github.com/go-openapi/analysis"
	"github.com/go-openapi/loads"
	"github.com/go-swagger/go-swagger/cmd/swagger/commands/generate"
	flags "github.com/jessevdk/go-flags"
)

// FlattenSpec is a command that flattens a swagger document
// which will expand the remote references in a spec and move inline schemas to definitions
// after flattening there are no complex inlined anymore
type FlattenSpec struct {
	Compact bool           `long:"compact" description:"applies to JSON formatted specs. When present, doesn't prettify the json"`
	Output  flags.Filename `long:"output" short:"o
    
func (c *FlattenSpec) Execute(args []string) error {
	if len(args) != 1 {
		return errors.New("flatten command requires the single swagger document url to be specified")
	}

	swaggerDoc := args[0]
	specDoc, err := loads.Spec(swaggerDoc)
	if err != nil {
		return err
	}

	flattenOpts := c.FlattenCmdOptions.SetFlattenOptions(&analysis.FlattenOpts{
		// defaults
		Minimal:      true,
		Verbose:      true,
		Expand:       false,
		RemoveUnused: false,
	})
	flattenOpts.BasePath = specDoc.SpecFilePath()
	flattenOpts.Spec = analysis.New(specDoc.Spec())
	if err := analysis.Flatten(*flattenOpts); err != nil {
		return err
	}

	return writeToFile(specDoc.Spec(), !c.Compact, c.Format, string(c.Output))
}