mirror of
https://github.com/rsteube/carapace-bin.git
synced 2025-05-05 15:32:53 +00:00
lslocks: updated to util-linux 2.41
This commit is contained in:
parent
b6a7fb6603
commit
2e2672f678
@ -1,18 +1,24 @@
|
||||
package action
|
||||
|
||||
import "github.com/carapace-sh/carapace"
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/carapace-sh/carapace"
|
||||
)
|
||||
|
||||
func ActionColumns() carapace.Action {
|
||||
return carapace.ActionValuesDescribed(
|
||||
"COMMAND", "command of the process holding the lock",
|
||||
"PID", "PID of the process holding the lock",
|
||||
"TYPE", "kind of lock",
|
||||
"SIZE", "size of the lock",
|
||||
"MODE", "lock access mode",
|
||||
"M", "mandatory state of the lock: 0 (none), 1 (set)",
|
||||
"START", "relative byte offset of the lock",
|
||||
"END", "ending offset of the lock",
|
||||
"PATH", "path of the locked file",
|
||||
"BLOCKER", "PID of the process blocking the lock",
|
||||
)
|
||||
return carapace.ActionExecCommand("lslocks", "--list-columns")(func(output []byte) carapace.Action {
|
||||
re := regexp.MustCompile(`^\s*(\S+)\s+<[^>]+>\s+(.*)$`)
|
||||
var values []string
|
||||
|
||||
for _, line := range strings.Split(string(output), "\n") {
|
||||
if matches := re.FindStringSubmatch(line); len(matches) == 3 {
|
||||
name, description := matches[1], matches[2]
|
||||
values = append(values, name, description)
|
||||
}
|
||||
}
|
||||
|
||||
return carapace.ActionValuesDescribed(values...)
|
||||
})
|
||||
}
|
||||
|
@ -17,12 +17,14 @@ var rootCmd = &cobra.Command{
|
||||
func Execute() error {
|
||||
return rootCmd.Execute()
|
||||
}
|
||||
|
||||
func init() {
|
||||
carapace.Gen(rootCmd).Standalone()
|
||||
|
||||
rootCmd.Flags().BoolP("bytes", "b", false, "print SIZE in bytes rather than in human readable format")
|
||||
rootCmd.Flags().BoolP("help", "h", false, "display this help")
|
||||
rootCmd.Flags().BoolP("json", "J", false, "use JSON output format")
|
||||
rootCmd.Flags().BoolP("list-columns", "H", false, "list the available columns")
|
||||
rootCmd.Flags().BoolP("noheadings", "n", false, "don't print headings")
|
||||
rootCmd.Flags().BoolP("noinaccessible", "i", false, "ignore locks without read permissions")
|
||||
rootCmd.Flags().BoolP("notruncate", "u", false, "don't truncate text in columns")
|
||||
|
Loading…
x
Reference in New Issue
Block a user