mirror of
https://github.com/rsteube/carapace-bin.git
synced 2025-05-05 15:32:53 +00:00
Added lsclocks completer
This commit is contained in:
parent
2e2672f678
commit
529beb6193
29
completers/lsclocks_completer/cmd/action/action.go
Normal file
29
completers/lsclocks_completer/cmd/action/action.go
Normal file
@ -0,0 +1,29 @@
|
||||
package action
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/carapace-sh/carapace"
|
||||
)
|
||||
|
||||
func ActionColumns() carapace.Action {
|
||||
return carapace.ActionValuesDescribed(
|
||||
"TYPE", "type",
|
||||
"ID", "numeric id",
|
||||
"CLOCK", "symbolic name",
|
||||
"NAME", "readable name",
|
||||
"TIME", "numeric time",
|
||||
"ISO_TIME", "human readable ISO time",
|
||||
"RESOL", "human readable resolution",
|
||||
"RESOL_RAW", "resolution",
|
||||
"REL_TIME", "human readable relative time",
|
||||
"NS_OFFSET", "namespace offset",
|
||||
)
|
||||
}
|
||||
|
||||
func ActionClocks() carapace.Action {
|
||||
return carapace.ActionExecCommand("lsclocks", "--output", "CLOCK")(func(output []byte) carapace.Action {
|
||||
lines := strings.Split(string(output), "\n")
|
||||
return carapace.ActionValues(lines[1:]...)
|
||||
})
|
||||
}
|
42
completers/lsclocks_completer/cmd/root.go
Normal file
42
completers/lsclocks_completer/cmd/root.go
Normal file
@ -0,0 +1,42 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/carapace-sh/carapace"
|
||||
"github.com/carapace-sh/carapace-bin/completers/lsclocks_completer/cmd/action"
|
||||
"github.com/carapace-sh/carapace-bin/pkg/actions/ps"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "lsclocks",
|
||||
Short: "display system clocks",
|
||||
Long: "https://man7.org/linux/man-pages/man1/lsclocks.1.html",
|
||||
Run: func(cmd *cobra.Command, args []string) {},
|
||||
}
|
||||
|
||||
func Execute() error {
|
||||
return rootCmd.Execute()
|
||||
}
|
||||
|
||||
func init() {
|
||||
carapace.Gen(rootCmd).Standalone()
|
||||
|
||||
rootCmd.Flags().StringP("cpu-clock", "c", "", "also display CPU clock of specified process")
|
||||
rootCmd.Flags().StringP("dynamic-clock", "d", "", "also display specified dynamic clock")
|
||||
rootCmd.Flags().BoolP("help", "h", false, "display this help")
|
||||
rootCmd.Flags().BoolP("json", "J", false, "use JSON output format")
|
||||
rootCmd.Flags().Bool("no-discover-dynamic", false, "do not try to discover dynamic clocks")
|
||||
rootCmd.Flags().BoolP("noheadings", "n", false, "don't print headings")
|
||||
rootCmd.Flags().StringP("output", "o", "", "output columns")
|
||||
rootCmd.Flags().Bool("output-all", false, "output all columns")
|
||||
rootCmd.Flags().BoolP("raw", "r", false, "use raw output format")
|
||||
rootCmd.Flags().StringP("time", "t", "", "show current time of single clock")
|
||||
rootCmd.Flags().BoolP("version", "V", false, "display version")
|
||||
|
||||
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
|
||||
"cpu-clock": ps.ActionProcessIds(),
|
||||
"dynamic-clock": carapace.ActionFiles(),
|
||||
"output": action.ActionColumns().UniqueList(","),
|
||||
"time": action.ActionClocks(),
|
||||
})
|
||||
}
|
7
completers/lsclocks_completer/main.go
Normal file
7
completers/lsclocks_completer/main.go
Normal file
@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "github.com/carapace-sh/carapace-bin/completers/lsclocks_completer/cmd"
|
||||
|
||||
func main() {
|
||||
cmd.Execute()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user