MCPcopy Create free account
hub / github.com/dim-an/cod / handleParseCommandLine

Method handleParseCommandLine

server/server.go:564–612  ·  view source on GitHub ↗
(req *ParseCommandLineRequest)

Source from the content-addressed store, hash-verified

562}
563
564func (s *serverImpl) handleParseCommandLine(req *ParseCommandLineRequest) (rsp ParseCommandLineResponse, err error, warns []util.Warning) {
565 rsp.Env, rsp.Args, err = shells.ParseSimpleCommand(req.CommandLine)
566 if err != nil {
567 if errors.Is(err, shells.ErrCommandNotSimple) {
568 err = nil
569 }
570 return
571 }
572
573 rsp.IsHelpCommand = false
574loop:
575 for _, a := range rsp.Args {
576 switch a {
577 case "--help":
578 rsp.IsHelpCommand = true
579 break loop
580 case "--":
581 break loop
582 }
583 }
584
585 var executablePath string
586 if len(rsp.Args) > 0 {
587 executablePath, err = datastore.CanonizeExecutablePath(
588 rsp.Args[0],
589 req.Dir,
590 util.GetPathVar(req.Env),
591 util.GetHomeVar(req.Env),
592 )
593 if err != nil {
594 return
595 }
596 rsp.Args[0] = executablePath
597 var policy datastore.Policy
598 policy, err = s.storage.GetCommandPolicy(rsp.Args)
599 if err != nil {
600 return
601 }
602 if policy != datastore.PolicyUnknown {
603 rsp.PolicyMode = policy
604 } else if policy = s.userConfiguration.GetExecutablePolicy(rsp.Args[0]); policy != datastore.PolicyUnknown {
605 rsp.PolicyMode = policy
606 } else {
607 rsp.PolicyMode = datastore.PolicyAsk
608 }
609 }
610
611 return
612}
613
614func (s *serverImpl) handleUpdateHelpPageRequest(req *UpdateHelpPageRequest, warner *util.Warner) (rsp UpdateHelpPageResponse, err error) {
615 cmd := req.Command

Callers 1

handleRequestMethod · 0.95

Calls 6

ParseSimpleCommandFunction · 0.92
CanonizeExecutablePathFunction · 0.92
GetPathVarFunction · 0.92
GetHomeVarFunction · 0.92
GetExecutablePolicyMethod · 0.80
GetCommandPolicyMethod · 0.65

Tested by

no test coverage detected