mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 21:16:30 +02:00
Optionally show filenames in list output (#248)
This commit is contained in:
parent
ac6a590f52
commit
1cd848264d
15
cmd/list.go
15
cmd/list.go
@ -3,9 +3,11 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/packwiz/packwiz/core"
|
"github.com/packwiz/packwiz/core"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
// listCmd represents the list command
|
// listCmd represents the list command
|
||||||
@ -36,13 +38,26 @@ var listCmd = &cobra.Command{
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort.Slice(mods, func(i, j int) bool {
|
||||||
|
return mods[i].Name < mods[j].Name
|
||||||
|
})
|
||||||
|
|
||||||
// Print mods
|
// Print mods
|
||||||
|
if viper.GetBool("list.version") {
|
||||||
|
for _, mod := range mods {
|
||||||
|
fmt.Printf("%s\t[%s]\n", mod.Name, mod.FileName)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for _, mod := range mods {
|
for _, mod := range mods {
|
||||||
fmt.Println(mod.Name)
|
fmt.Println(mod.Name)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(listCmd)
|
rootCmd.AddCommand(listCmd)
|
||||||
|
|
||||||
|
listCmd.Flags().BoolP("version", "v", false, "Print name and version")
|
||||||
|
_ = viper.BindPFlag("list.version", listCmd.Flags().Lookup("version"))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user