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