-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jens Drenhaus <jens.drenhaus@blindspot.software>
- Loading branch information
1 parent
5c41ffa
commit 80fc4bc
Showing
7 changed files
with
367 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"connectrpc.com/connect" | ||
"github.com/BlindspotSoftware/dutctl/pkg/dut" | ||
) | ||
|
||
func findCmd(list dut.Devlist, wantDev, wantCmd string) (dut.Device, dut.Command, error) { | ||
var ( | ||
dev dut.Device | ||
cmd dut.Command | ||
) | ||
|
||
dev, ok := list[wantDev] | ||
if !ok { | ||
e := connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("device %q does not exist", wantDev)) | ||
|
||
return dev, cmd, e | ||
} | ||
|
||
cmd, ok = dev.Cmds[wantCmd] | ||
if !ok { | ||
e := connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("device %q does not have command %q", wantDev, wantCmd)) | ||
|
||
return dev, cmd, e | ||
} | ||
|
||
if len(cmd.Modules) == 0 { | ||
e := connect.NewError(connect.CodeInternal, fmt.Errorf("no modules set for command %q at device %q", wantCmd, wantDev)) | ||
|
||
return dev, cmd, e | ||
} | ||
|
||
return dev, cmd, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.