mirror of
https://github.com/rsteube/carapace-bin.git
synced 2025-05-05 15:32:53 +00:00
Added timeout completer
This commit is contained in:
parent
10c2e66109
commit
9adbe356a6
44
completers/timeout_completer/cmd/root.go
Normal file
44
completers/timeout_completer/cmd/root.go
Normal file
@ -0,0 +1,44 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/carapace-sh/carapace"
|
||||
"github.com/carapace-sh/carapace-bin/pkg/actions/ps"
|
||||
"github.com/carapace-sh/carapace-bridge/pkg/actions/bridge"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "timeout",
|
||||
Short: "run a command with a time limit",
|
||||
Long: "https://man7.org/linux/man-pages/man1/timeout.1.html",
|
||||
Run: func(cmd *cobra.Command, args []string) {},
|
||||
}
|
||||
|
||||
func Execute() error {
|
||||
return rootCmd.Execute()
|
||||
}
|
||||
|
||||
func init() {
|
||||
carapace.Gen(rootCmd).Standalone()
|
||||
rootCmd.Flags().SetInterspersed(false)
|
||||
|
||||
rootCmd.Flags().BoolP("foreground", "f", false, "when not running timeout directly from a shell prompt, allow COMMAND to read from the TTY and get TTY signals")
|
||||
rootCmd.Flags().Bool("help", false, "display this help and exit")
|
||||
rootCmd.Flags().StringP("kill-after", "k", "", "also send a KILL signal if COMMAND is still running this long after the initial signal was sent")
|
||||
rootCmd.Flags().BoolP("preserve-status", "p", false, "exit with the same status as COMMAND, even when the command times out")
|
||||
rootCmd.Flags().StringP("signal", "s", "", "specify the signal to be sent on timeout")
|
||||
rootCmd.Flags().BoolP("verbose", "v", false, "diagnose to stderr any signal sent upon timeout")
|
||||
rootCmd.Flags().Bool("version", false, "output version information and exit")
|
||||
|
||||
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
|
||||
"signal": ps.ActionKillSignals(),
|
||||
})
|
||||
|
||||
carapace.Gen(rootCmd).PositionalCompletion(
|
||||
carapace.ActionValues(),
|
||||
)
|
||||
|
||||
carapace.Gen(rootCmd).PositionalAnyCompletion(
|
||||
bridge.ActionCarapaceBin().Shift(1),
|
||||
)
|
||||
}
|
7
completers/timeout_completer/main.go
Normal file
7
completers/timeout_completer/main.go
Normal file
@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "github.com/carapace-sh/carapace-bin/completers/timeout_completer/cmd"
|
||||
|
||||
func main() {
|
||||
cmd.Execute()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user