Skip to content

Commit 6b546a0

Browse files
authored
Merge pull request #146 from kindlyops/coral
migrate from cobra to coral
2 parents 7559d0a + 2d93fbd commit 6b546a0

40 files changed

+95
-744
lines changed

cmd/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ go_library(
2727
"//vendor/github.com/hypebeast/go-osc/osc:go_default_library",
2828
"//vendor/github.com/kennygrant/sanitize:go_default_library",
2929
"//vendor/github.com/mattn/go-isatty:go_default_library",
30+
"//vendor/github.com/muesli/coral:go_default_library",
3031
"//vendor/github.com/rs/zerolog:go_default_library",
3132
"//vendor/github.com/rs/zerolog/log:go_default_library",
32-
"//vendor/github.com/spf13/cobra:go_default_library",
3333
"//vendor/github.com/spf13/viper:go_default_library",
3434
] + select({
3535
"@io_bazel_rules_go//go/platform:windows": [

cmd/chapters.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,27 @@ import (
2626
"sync"
2727

2828
"github.com/kennygrant/sanitize"
29+
"github.com/muesli/coral"
2930
"github.com/rs/zerolog/log"
30-
"github.com/spf13/cobra"
3131
)
3232

33-
var chapterListCmd = &cobra.Command{
33+
var chapterListCmd = &coral.Command{
3434
Use: "chapterlist <videofile.mp4>",
3535
Short: "List chapters in a video container.",
3636
Long: `Use ffprobe to discover all chapter metadata in a video file container.`,
3737
Run: chapterList,
38-
Args: cobra.ExactArgs(1),
38+
Args: coral.ExactArgs(1),
3939
}
4040

41-
var chapterSplitCmd = &cobra.Command{
41+
var chapterSplitCmd = &coral.Command{
4242
Use: "chaptersplit <videofile.mp4>",
4343
Short: "Split video file into separate files per chapter.",
4444
Long: `Use ffmpeg to copy each chapter from a video file into it's own file.`,
4545
Run: chapterSplit,
46-
Args: cobra.ExactArgs(1),
46+
Args: coral.ExactArgs(1),
4747
}
4848

49-
func chapterSplit(cmd *cobra.Command, args []string) {
49+
func chapterSplit(cmd *coral.Command, args []string) {
5050
_, err := exec.LookPath("ffprobe")
5151

5252
if err != nil {
@@ -175,7 +175,7 @@ func getChapters(target string) (ffmprobeResponse, error) {
175175
return response, nil
176176
}
177177

178-
func chapterList(cmd *cobra.Command, args []string) {
178+
func chapterList(cmd *coral.Command, args []string) {
179179
_, err := exec.LookPath("ffprobe")
180180

181181
if err != nil {

cmd/ivs.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@ import (
2121
"github.com/aws/aws-sdk-go/aws/session"
2222
"github.com/aws/aws-sdk-go/service/ivs"
2323
"github.com/hypebeast/go-osc/osc"
24+
"github.com/muesli/coral"
2425
"github.com/rs/zerolog/log"
25-
"github.com/spf13/cobra"
2626
"github.com/spf13/viper"
2727
)
2828

29-
var ivsOscBridgeCmd = &cobra.Command{
29+
var ivsOscBridgeCmd = &coral.Command{
3030
Use: "ivs-bridge <ivs-stream-arn>",
3131
Short: "Connect OSC commands to IVS PutMetadata.",
3232
Long: `Use OSC to send messages to IVS using PutMetadata API.`,
3333
Run: ivsOscBridge,
34-
Args: cobra.ExactArgs(1),
34+
Args: coral.ExactArgs(1),
3535
}
3636

37-
var ivsPutMetadataCmd = &cobra.Command{
37+
var ivsPutMetadataCmd = &coral.Command{
3838
Use: "ivs-put <ivs-stream-arn> <data payload>",
3939
Short: "Send payload to IVS PutMetadata.",
4040
Long: `Send messages to IVS using PutMetadata API.`,
4141
Run: ivsPutMetadata,
42-
Args: cobra.ExactArgs(2), //nolint:gomnd // this is an appropriate magic number
42+
Args: coral.ExactArgs(2), //nolint:gomnd // this is an appropriate magic number
4343
}
4444

45-
func ivsOscBridge(cmd *cobra.Command, args []string) {
45+
func ivsOscBridge(cmd *coral.Command, args []string) {
4646
arn := args[0]
4747
addr := "127.0.0.1:" + viper.GetString("ivs_port")
4848

@@ -76,7 +76,7 @@ func ivsOscBridge(cmd *cobra.Command, args []string) {
7676
}
7777
}
7878

79-
func ivsPutMetadata(cmd *cobra.Command, args []string) {
79+
func ivsPutMetadata(cmd *coral.Command, args []string) {
8080
arn := args[0]
8181
data := args[1]
8282

cmd/lighting.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ import (
2121

2222
"github.com/hypebeast/go-osc/osc"
2323
"github.com/kindlyops/vbs/embeddy"
24+
"github.com/muesli/coral"
2425
"github.com/rs/zerolog/log"
25-
"github.com/spf13/cobra"
2626
"github.com/spf13/viper"
2727
)
2828

29-
var lightingBridgeCmd = &cobra.Command{
29+
var lightingBridgeCmd = &coral.Command{
3030
Use: "lighting-bridge <companion-ip>",
3131
Short: "Serve embedded lighting control page",
3232
Long: `Use OSC to send messages to Companion API for lighting control.`,
3333
Run: lightingBridge,
34-
Args: cobra.NoArgs,
34+
Args: coral.NoArgs,
3535
}
3636

37-
func lightingBridge(cmd *cobra.Command, args []string) {
37+
func lightingBridge(cmd *coral.Command, args []string) {
3838
listenAddr := "127.0.0.1:" + viper.GetString("lighting_port")
3939
dist, _ := fs.Sub(embeddy.GetNextFS(), "dist")
4040

cmd/play.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ import (
3333
"github.com/charmbracelet/bubbles/spinner"
3434
tea "github.com/charmbracelet/bubbletea"
3535
"github.com/charmbracelet/lipgloss"
36+
"github.com/muesli/coral"
3637
"github.com/rs/zerolog/log"
37-
"github.com/spf13/cobra"
3838
)
3939

40-
var playCmd = &cobra.Command{
40+
var playCmd = &coral.Command{
4141
Use: "play <videofile.mp4>",
4242
Short: "Play a videofile fullscreen with mpv player.",
4343
Long: `Use mpv video player to play a video file fullscreen on the designated display.`,
4444
Run: play,
45-
Args: cobra.ExactArgs(1),
45+
Args: coral.ExactArgs(1),
4646
}
4747

4848
// keyMap defines a set of keybindings. To work for help it must satisfy
@@ -525,7 +525,7 @@ func (m model) View() string {
525525
Render(s)
526526
}
527527

528-
func play(cmd *cobra.Command, args []string) {
528+
func play(cmd *coral.Command, args []string) {
529529
_, err := exec.LookPath("mpv")
530530

531531
if err != nil {

cmd/root.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import (
2121
"time"
2222

2323
"github.com/mattn/go-isatty"
24+
"github.com/muesli/coral"
2425
"github.com/rs/zerolog"
2526
"github.com/rs/zerolog/log"
26-
"github.com/spf13/cobra"
2727
"github.com/spf13/viper"
2828
)
2929

@@ -33,7 +33,7 @@ var cfgFile string
3333
var Debug bool
3434

3535
// rootCmd represents the base command when called without any subcommands.
36-
var rootCmd = &cobra.Command{
36+
var rootCmd = &coral.Command{
3737
Version: "dev",
3838
Use: "vbs",
3939
Short: "video broadcasting stuff",
@@ -55,15 +55,15 @@ use at your own risk.
5555
// Run: func(cmd *cobra.Command, args []string) { },
5656
}
5757

58-
var configCmd = &cobra.Command{
58+
var configCmd = &coral.Command{
5959
Use: "save-config",
6060
Short: "Save the current config.",
6161
Long: `Save the current config after merge from files, arguments, and environment.`,
6262
Run: saveConfig,
63-
Args: cobra.NoArgs,
63+
Args: coral.NoArgs,
6464
}
6565

66-
func saveConfig(cmd *cobra.Command, args []string) {
66+
func saveConfig(cmd *coral.Command, args []string) {
6767
configDir, err := os.UserConfigDir()
6868
if err != nil {
6969
log.Fatal().Stack().Err(err).Msg("Couldn't locate config dir")
@@ -105,7 +105,7 @@ func init() {
105105
log.Logger = log.With().Caller().Logger()
106106
}
107107

108-
cobra.OnInitialize(initConfig)
108+
coral.OnInitialize(initConfig)
109109

110110
// Here you will define your flags and configuration settings.
111111
// Cobra supports persistent flags, which, if defined here,

dummy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build neverbuild
12
// +build neverbuild
23

34
package main

embeddy/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ next(
3434
)
3535

3636
next(
37-
name = "build",
37+
name = "next_export",
3838
outs = ["dist"],
3939
args = [
4040
"export $(RULEDIR)",
@@ -53,7 +53,7 @@ static_site_embedder(
5353
go_library(
5454
name = "go_default_library",
5555
srcs = [":embedder"],
56-
embedsrcs = [":build"],
56+
embedsrcs = [":next_export"],
5757
importpath = "github.com/kindlyops/vbs/embeddy",
5858
visibility = ["//visibility:public"],
5959
)

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require (
88
github.com/kennygrant/sanitize v1.2.4
99
github.com/mattn/go-isatty v0.0.14
1010
github.com/rs/zerolog v1.26.1
11-
github.com/spf13/cobra v1.3.0
1211
github.com/spf13/viper v1.10.1
1312
)
1413

@@ -17,6 +16,7 @@ require (
1716
github.com/charmbracelet/bubbles v0.10.3
1817
github.com/charmbracelet/bubbletea v0.20.0
1918
github.com/charmbracelet/lipgloss v0.5.0
19+
github.com/muesli/coral v1.0.0
2020
)
2121

2222
require (
@@ -26,6 +26,7 @@ require (
2626
github.com/hashicorp/hcl v1.0.0 // indirect
2727
github.com/inconshreveable/mousetrap v1.0.0 // indirect
2828
github.com/jmespath/go-jmespath v0.4.0 // indirect
29+
github.com/kr/pretty v0.2.0 // indirect
2930
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
3031
github.com/magiconair/properties v1.8.5 // indirect
3132
github.com/mattn/go-runewidth v0.0.13 // indirect
@@ -44,6 +45,7 @@ require (
4445
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
4546
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
4647
golang.org/x/text v0.3.7 // indirect
48+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
4749
gopkg.in/ini.v1 v1.66.2 // indirect
4850
gopkg.in/yaml.v2 v2.4.0 // indirect
4951
)

0 commit comments

Comments
 (0)