Skip to content

Commit

Permalink
added asciicast
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Sep 9, 2020
1 parent 6c26402 commit d554217
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 0 deletions.
4 changes: 4 additions & 0 deletions carapace/cmd/completers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
asciinema "github.com/rsteube/carapace-bin/completers/asciinema_completer/cmd"
basename "github.com/rsteube/carapace-bin/completers/basename_completer/cmd"
bat "github.com/rsteube/carapace-bin/completers/bat_completer/cmd"
cat "github.com/rsteube/carapace-bin/completers/cat_completer/cmd"
Expand Down Expand Up @@ -92,6 +93,7 @@ import (
)

var completers = []string{
"asciinema",
"basename",
"bat",
"cat",
Expand Down Expand Up @@ -184,6 +186,8 @@ var completers = []string{

func executeCompleter(completer string) {
switch completer {
case "asciinema":
asciinema.Execute()
case "basename":
basename.Execute()
case "bat":
Expand Down
19 changes: 19 additions & 0 deletions completers/asciinema_completer/cmd/auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var authCmd = &cobra.Command{
Use: "auth",
Short: "Manage recordings on asciinema.org account",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(authCmd).Standalone()

authCmd.Flags().BoolP("help", "h", false, "show this help message and exit")
rootCmd.AddCommand(authCmd)
}
23 changes: 23 additions & 0 deletions completers/asciinema_completer/cmd/cat.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var catCmd = &cobra.Command{
Use: "cat",
Short: "Print full output of recorded session",
Run: func(cmd *cobra.Command, args []string) {},
}

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(
carapace.ActionFiles(""),
)
}
25 changes: 25 additions & 0 deletions completers/asciinema_completer/cmd/play.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var playCmd = &cobra.Command{
Use: "play",
Short: "Replay terminal recording",
Run: func(cmd *cobra.Command, args []string) {},
}

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)")
rootCmd.AddCommand(playCmd)

carapace.Gen(playCmd).PositionalCompletion(
carapace.ActionFiles(""),
)
}
37 changes: 37 additions & 0 deletions completers/asciinema_completer/cmd/rec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var recCmd = &cobra.Command{
Use: "rec",
Short: "Record terminal session",
Run: func(cmd *cobra.Command, args []string) {},
}

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)")
rootCmd.AddCommand(recCmd)

carapace.Gen(recCmd).FlagCompletion(carapace.ActionMap{
"command": carapace.ActionFiles(""), // TODO PATH binaries
})

carapace.Gen(recCmd).PositionalCompletion(
carapace.ActionFiles(""),
)
}
22 changes: 22 additions & 0 deletions completers/asciinema_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "asciinema",
Short: "Record and share your terminal sessions, the right way.",
Run: func(cmd *cobra.Command, args []string) {},
}

func Execute() error {
return rootCmd.Execute()
}
func init() {
carapace.Gen(rootCmd).Standalone()

rootCmd.Flags().BoolP("help", "h", false, "show this help message and exit")
rootCmd.Flags().Bool("version", false, "show program's version number and exit")
}
23 changes: 23 additions & 0 deletions completers/asciinema_completer/cmd/upload.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var uploadCmd = &cobra.Command{
Use: "upload",
Short: "Upload locally saved terminal session to asciinema.org",
Run: func(cmd *cobra.Command, args []string) {},
}

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(
carapace.ActionFiles(""),
)
}
7 changes: 7 additions & 0 deletions completers/asciinema_completer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/rsteube/carapace-bin/completers/asciinema_completer/cmd"

func main() {
cmd.Execute()
}

0 comments on commit d554217

Please sign in to comment.