MCPcopy Create free account
hub / github.com/1buran/rHttp / Update

Method Update

fileinput.go:102–128  ·  view source on GitHub ↗
(msg tea.Msg)

Source from the content-addressed store, hash-verified

100}
101
102func (f FileInput) Update(msg tea.Msg) (FileInput, tea.Cmd) {
103 var c1, c2 tea.Cmd
104 switch msg := msg.(type) {
105 case OpenFileReadMsg:
106 if msg.Id != f.id {
107 return f, nil
108 }
109 p := f.widget.Value()
110 r, err := os.Open(p)
111 c2 = func() tea.Msg {
112 return FileInputReader{f.id, r, err, p}
113 }
114 f.Hide()
115 case OpenFileWriteMsg:
116 if msg.Id != f.id {
117 return f, nil
118 }
119 p := f.widget.Value()
120 w, err := os.Create(p)
121 c2 = func() tea.Msg {
122 return FileInputWriter{f.id, w, err, p}
123 }
124 f.Hide()
125 }
126 f.widget, c1 = f.widget.Update(msg)
127 return f, tea.Batch(c1, c2)
128}

Callers

nothing calls this directly

Calls 2

HideMethod · 0.95
ValueMethod · 0.80

Tested by

no test coverage detected