package carapace

import (
	

	
	
	
	
	
	
)

func complete( *cobra.Command,  []string) (string, error) {
	switch len() {
	case 0:
		return Gen().Snippet(ps.DetermineShell())
	case 1:
		return Gen().Snippet([0])
	default:
		initHelpCompletion()

		switch ps.DetermineShell() {
		case "nushell":
			 = nushell.Patch() // handle open quotes
			LOG.Printf("patching args to %#v", )
		case "bash": // TODO what about oil and such?
			LOG.Printf("COMP_LINE is %#v", os.Getenv("COMP_LINE"))
			LOG.Printf("COMP_POINT is %#v", os.Getenv("COMP_POINT"))
			var  error
			,  = bash.Patch() // handle redirects
			LOG.Printf("patching args to %#v", )
			if  != nil {
				 := NewContext(...)
				if ,  := .(bash.RedirectError);  {
					LOG.Printf("completing redirect target for %#v", )
					return ActionFiles().Invoke().value([0], [len()-1]), nil
				}
				return ActionMessage(.Error()).Invoke().value([0], [len()-1]), nil
			}
		case "cmd-clink":
			var  error
			,  = cmd_clink.Patch()
			LOG.Printf("patching args to %#v", )
			if  != nil {
				 := NewContext(...)
				return ActionMessage(.Error()).Invoke().value([0], [len()-1]), nil
			}
		}

		,  := traverse(, [2:])
		if  := config.Load();  != nil {
			 = ActionMessage("failed to load config: " + .Error())
		}
		return .Invoke().value([0], [len()-1]), nil
	}
}