MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / fileInfoRun

Function fileInfoRun

cmd/wsh/cmd/wshcmd-file.go:187–221  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

185}
186
187func fileInfoRun(cmd *cobra.Command, args []string) error {
188 path, err := fixRelativePaths(args[0])
189 if err != nil {
190 return err
191 }
192 fileData := wshrpc.FileData{
193 Info: &wshrpc.FileInfo{
194 Path: path}}
195
196 info, err := wshclient.FileInfoCommand(RpcClient, fileData, &wshrpc.RpcOpts{Timeout: fileTimeout})
197 err = convertNotFoundErr(err)
198 if err != nil {
199 return fmt.Errorf("getting file info: %w", err)
200 }
201
202 if info.NotFound {
203 return fmt.Errorf("%s: no such file", path)
204 }
205
206 WriteStdout("name:\t%s\n", info.Name)
207 if info.Mode != 0 {
208 WriteStdout("mode:\t%s\n", info.Mode.String())
209 }
210 WriteStdout("mtime:\t%s\n", time.Unix(info.ModTime/1000, 0).Format(time.DateTime))
211 if !info.IsDir {
212 WriteStdout("size:\t%d\n", info.Size)
213 }
214 if info.Meta != nil && len(*info.Meta) > 0 {
215 WriteStdout("metadata:\n")
216 for k, v := range *info.Meta {
217 WriteStdout("\t\t\t%s: %v\n", k, v)
218 }
219 }
220 return nil
221}
222
223func fileRmRun(cmd *cobra.Command, args []string) error {
224 path, err := fixRelativePaths(args[0])

Callers

nothing calls this directly

Calls 5

FileInfoCommandFunction · 0.92
fixRelativePathsFunction · 0.85
convertNotFoundErrFunction · 0.85
WriteStdoutFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected