asciinema: updates from 3.0.0-rc.3

This commit is contained in:
rsteube 2025-02-23 19:21:16 +01:00
parent a75ca58767
commit 61568aa9af
9 changed files with 120 additions and 19 deletions

View File

@ -14,6 +14,5 @@ var authCmd = &cobra.Command{
func init() {
carapace.Gen(authCmd).Standalone()
authCmd.Flags().BoolP("help", "h", false, "show this help message and exit")
rootCmd.AddCommand(authCmd)
}

View File

@ -14,7 +14,6 @@ var catCmd = &cobra.Command{
func init() {
carapace.Gen(catCmd).Standalone()
catCmd.Flags().BoolP("help", "h", false, "show this help message and exit")
rootCmd.AddCommand(catCmd)
carapace.Gen(catCmd).PositionalCompletion(

View File

@ -0,0 +1,32 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var convertCmd = &cobra.Command{
Use: "convert",
Short: "Convert a recording into another format",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(convertCmd).Standalone()
convertCmd.Flags().StringP("format", "f", "", "Output file format")
convertCmd.Flags().BoolP("help", "h", false, "Print help")
convertCmd.Flags().Bool("overwrite", false, "Overwrite target file if it already exists")
convertCmd.Flags().BoolP("quiet", "q", false, "Quiet mode, i.e. suppress diagnostic messages")
convertCmd.Flags().String("server-url", "", "asciinema server URL")
rootCmd.AddCommand(convertCmd)
carapace.Gen(convertCmd).FlagCompletion(carapace.ActionMap{
"format": carapace.ActionValues("asciicast", "raw", "txt"),
})
carapace.Gen(convertCmd).PositionalCompletion(
carapace.ActionFiles(),
carapace.ActionFiles(),
)
}

View File

@ -0,0 +1,23 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var helpCmd = &cobra.Command{
Use: "help",
Short: "Print this message or the help of the given subcommand(s)",
Run: func(cmd *cobra.Command, args []string) {},
DisableFlagParsing: true,
}
func init() {
carapace.Gen(helpCmd).Standalone()
rootCmd.AddCommand(helpCmd)
carapace.Gen(helpCmd).PositionalCompletion(
carapace.ActionCommands(rootCmd),
)
}

View File

@ -14,9 +14,11 @@ var playCmd = &cobra.Command{
func init() {
carapace.Gen(playCmd).Standalone()
playCmd.Flags().BoolP("help", "h", false, "show this help message and exit")
playCmd.Flags().StringP("idle-time-limit", "i", "", "limit idle time during playback to given number of seconds")
playCmd.Flags().StringP("speed", "s", "", "playback speedup (can be fractional)")
playCmd.Flags().StringP("idle-time-limit", "i", "", "Limit idle time to a given number of seconds")
playCmd.Flags().BoolP("loop", "l", false, "Loop loop loop loop")
playCmd.Flags().BoolP("pause-on-markers", "m", false, "Automatically pause on markers")
playCmd.Flags().StringP("speed", "s", "", "Set playback speed")
rootCmd.AddCommand(playCmd)
carapace.Gen(playCmd).PositionalCompletion(

View File

@ -15,17 +15,20 @@ var recCmd = &cobra.Command{
func init() {
carapace.Gen(recCmd).Standalone()
recCmd.Flags().Bool("append", false, "append to existing recording")
recCmd.Flags().StringP("command", "c", "", "command to record, defaults to $SHELL")
recCmd.Flags().StringP("env", "e", "", "list of environment variables to capture")
recCmd.Flags().BoolP("help", "h", false, "show this help message and exit")
recCmd.Flags().StringP("idle-time-limit", "i", "", "limit recorded idle time to given number of seconds")
recCmd.Flags().Bool("overwrite", false, "overwrite the file if it already exists")
recCmd.Flags().BoolP("quiet", "q", false, "be quiet, suppress all notices/warnings (implies -y)")
recCmd.Flags().Bool("raw", false, "save only raw stdout output")
recCmd.Flags().Bool("stdin", false, "enable stdin recording, disabled by default")
recCmd.Flags().StringP("title", "t", "", "title of the asciicast")
recCmd.Flags().BoolP("yes", "y", false, "answer \"yes\" to all prompts (e.g. upload confirmation)")
recCmd.Flags().BoolP("append", "a", false, "Append to an existing recording file")
recCmd.Flags().StringP("command", "c", "", "Command to record")
recCmd.Flags().String("env", "", "List of env vars to save")
recCmd.Flags().String("filename", "", "Filename template, used when recording to a directory")
recCmd.Flags().StringP("format", "f", "", "Recording file format")
recCmd.Flags().Bool("headless", false, "Use headless mode - don't use TTY for input/output")
recCmd.Flags().BoolP("help", "h", false, "Print help")
recCmd.Flags().StringP("idle-time-limit", "i", "", "Limit idle time to a given number of seconds")
recCmd.Flags().BoolP("input", "I", false, "Enable input recording")
recCmd.Flags().Bool("overwrite", false, "Overwrite target file if it already exists")
recCmd.Flags().BoolP("quiet", "q", false, "Quiet mode, i.e. suppress diagnostic messages")
recCmd.Flags().StringP("title", "t", "", "Title of the recording")
recCmd.Flags().String("tty-size", "", "Override terminal size for the recorded command")
rootCmd.AddCommand(recCmd)
carapace.Gen(recCmd).FlagCompletion(carapace.ActionMap{
@ -33,7 +36,9 @@ func init() {
carapace.ActionFiles(),
carapace.ActionExecutables(),
).ToA(),
"env": os.ActionEnvironmentVariables().UniqueList(","),
"env": os.ActionEnvironmentVariables().UniqueList(","),
"filename": carapace.ActionFiles(),
"format": carapace.ActionValues("asciicast", "raw", "txt"),
})
carapace.Gen(recCmd).PositionalCompletion(

View File

@ -18,6 +18,8 @@ func Execute() error {
func init() {
carapace.Gen(rootCmd).Standalone()
rootCmd.Flags().BoolP("help", "h", false, "show this help message and exit")
rootCmd.PersistentFlags().BoolP("help", "h", false, "show this help message and exit")
rootCmd.PersistentFlags().BoolP("quiet", "q", false, "Quiet mode, i.e. suppress diagnostic messages")
rootCmd.PersistentFlags().String("server-url", "", "asciinema server URL")
rootCmd.Flags().Bool("version", false, "show program's version number and exit")
}

View File

@ -0,0 +1,40 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/net"
"github.com/spf13/cobra"
)
var streamCmd = &cobra.Command{
Use: "stream",
Short: "Stream a terminal session",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(streamCmd).Standalone()
streamCmd.Flags().StringP("command", "c", "", "Command to stream")
streamCmd.Flags().Bool("headless", false, "Use headless mode - don't use TTY for input/output")
streamCmd.Flags().BoolP("input", "I", false, "Enable input capture")
streamCmd.Flags().String("log-file", "", "Log file path")
streamCmd.Flags().StringP("relay", "r", "", "Relay the stream via an asciinema server")
streamCmd.Flags().StringP("serve", "s", "", "Serve the stream with the built-in HTTP server")
streamCmd.Flags().String("tty-size", "", "Override terminal size for the session")
rootCmd.AddCommand(streamCmd)
carapace.Gen(streamCmd).FlagCompletion(carapace.ActionMap{
"command": carapace.Batch(
carapace.ActionFiles(),
carapace.ActionExecutables(),
).ToA(),
"log-file": carapace.ActionFiles(),
"serve": carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action {
if len(c.Parts) == 0 {
return carapace.ActionValues()
}
return net.ActionPorts()
}),
})
}

View File

@ -14,7 +14,6 @@ var uploadCmd = &cobra.Command{
func init() {
carapace.Gen(uploadCmd).Standalone()
uploadCmd.Flags().BoolP("help", "h", false, "show this help message and exit")
rootCmd.AddCommand(uploadCmd)
carapace.Gen(uploadCmd).PositionalCompletion(