MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / RunModifyInstanceSelector

Function RunModifyInstanceSelector

tui/modify.go:865–889  ·  view source on GitHub ↗

RunModifyInstanceSelector shows an interactive instance selector for modify

(client *api.Client, instances []api.Instance)

Source from the content-addressed store, hash-verified

863
864// RunModifyInstanceSelector shows an interactive instance selector for modify
865func RunModifyInstanceSelector(client *api.Client, instances []api.Instance) (*api.Instance, error) {
866 InitCommonStyles(os.Stdout)
867 m := newModifyInstanceSelectorModel(instances)
868 p := tea.NewProgram(m)
869
870 finalModel, err := p.Run()
871 if err != nil {
872 return nil, fmt.Errorf("error running instance selector: %w", err)
873 }
874
875 result, ok := finalModel.(modifyInstanceSelectorModel)
876 if !ok {
877 return nil, fmt.Errorf("unexpected model type")
878 }
879
880 if result.cancelled {
881 return nil, ErrCancelled
882 }
883
884 if result.selected == nil {
885 return nil, ErrCancelled
886 }
887
888 return result.selected, nil
889}
890
891type modifyInstanceSelectorModel struct {
892 cursor int

Callers 1

runModifyFunction · 0.92

Calls 2

InitCommonStylesFunction · 0.85

Tested by

no test coverage detected