changed alias to a function

This commit is contained in:
Shreyas Goenka 2023-05-26 18:00:38 +02:00
parent c3bc6fd540
commit 95d8590e81
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 6 additions and 9 deletions

View File

@ -9,10 +9,9 @@ import (
"github.com/spf13/cobra"
)
type FileInfo filer.FileInfo
func (i *FileInfo) ExpandPath(root string) {
func expandPath(i filer.FileInfo, root string) filer.FileInfo {
i.Name = path.Join(root, i.Name)
return i
}
// lsCmd represents the ls command
@ -58,14 +57,12 @@ var lsCmd = &cobra.Command{
}
// compute output with expanded paths if necessary
output := make([]FileInfo, len(filesInfo))
for i, v := range filesInfo {
output[i] = FileInfo(v)
if absolute {
output[i].ExpandPath(rootPath)
for i := range filesInfo {
filesInfo[i] = expandPath(filesInfo[i], rootPath)
}
}
return cmdio.RenderWithTemplate(ctx, output, template)
return cmdio.RenderWithTemplate(ctx, filesInfo, template)
},
}