mirror of
https://github.com/rsteube/carapace-bin.git
synced 2025-05-05 15:32:53 +00:00
df: updated to GNU coreutils 9.7
This commit is contained in:
parent
fd4f955c6a
commit
2f19f2f611
31
completers/df_completer/cmd/action/action.go
Normal file
31
completers/df_completer/cmd/action/action.go
Normal file
@ -0,0 +1,31 @@
|
||||
package action
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/carapace-sh/carapace"
|
||||
)
|
||||
|
||||
func ActionColumns() carapace.Action {
|
||||
return carapace.ActionValuesDescribed(
|
||||
"source", "The source of the mount point, usually a device",
|
||||
"fstype", "File system type",
|
||||
"itotal", "Total number of inodes",
|
||||
"iused", "Number of used inodes",
|
||||
"iavail", "Number of available inodes",
|
||||
"ipcent", "Percentage of IUSED divided by ITOTAL",
|
||||
"size", "Total number of blocks",
|
||||
"used", "Number of used blocks",
|
||||
"avail", "Number of available blocks",
|
||||
"pcent", "Percentage of USED divided by SIZE",
|
||||
"file", "The file name if specified on the command line",
|
||||
"target", "The mount point",
|
||||
)
|
||||
}
|
||||
|
||||
func ActionFilesystemTypes() carapace.Action {
|
||||
return carapace.ActionExecCommand("df", "--output=fstype")(func(output []byte) carapace.Action {
|
||||
lines := strings.Split(string(output), "\n")
|
||||
return carapace.ActionValues(lines[1:]...)
|
||||
})
|
||||
}
|
@ -2,19 +2,21 @@ package cmd
|
||||
|
||||
import (
|
||||
"github.com/carapace-sh/carapace"
|
||||
"github.com/carapace-sh/carapace-bin/completers/df_completer/cmd/action"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "df",
|
||||
Short: "report file system disk space usage",
|
||||
Long: "https://linux.die.net/man/1/df",
|
||||
Long: "https://man7.org/linux/man-pages/man1/df.1.html",
|
||||
Run: func(cmd *cobra.Command, args []string) {},
|
||||
}
|
||||
|
||||
func Execute() error {
|
||||
return rootCmd.Execute()
|
||||
}
|
||||
|
||||
func init() {
|
||||
carapace.Gen(rootCmd).Standalone()
|
||||
|
||||
@ -37,13 +39,12 @@ func init() {
|
||||
rootCmd.Flags().BoolS("v", "v", false, "(ignored)")
|
||||
rootCmd.Flags().Bool("version", false, "output version information and exit")
|
||||
|
||||
types := []string{"adfs", "cgroup2", "efivarfs", "hfs", "pipefs", "securityfs", "ufs", "autofs", "configfs", "ext2", "hpfs", "proc", "sockfs", "vfat", "bdev", "cpuset", "ext3", "hugetlbfs", "pstore", "swap"}
|
||||
rootCmd.Flag("output").NoOptDefVal = " "
|
||||
|
||||
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
|
||||
// TODO should be lists of values (comma separated)
|
||||
"exclude-type": carapace.ActionValues(types...),
|
||||
"output": carapace.ActionValues("avail", "file", "fstype", "iavail", "ipcent", "itotal", "iused", "pcent", "size", "source", "target", "used"),
|
||||
"type": carapace.ActionValues(types...),
|
||||
"exclude-type": action.ActionFilesystemTypes(),
|
||||
"output": action.ActionColumns().UniqueList(","),
|
||||
"type": action.ActionFilesystemTypes(),
|
||||
})
|
||||
|
||||
carapace.Gen(rootCmd).PositionalAnyCompletion(
|
||||
|
Loading…
x
Reference in New Issue
Block a user