Skip to content

Commit

Permalink
Merge pull request #8 from dvonthenen/scaffold-cli-commands
Browse files Browse the repository at this point in the history
Initial Scaffolding for CLI
  • Loading branch information
davidvonthenen authored Jul 25, 2024
2 parents 48a2414 + 4735f1a commit 8e69fd5
Show file tree
Hide file tree
Showing 17 changed files with 445 additions and 21 deletions.
43 changes: 22 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
MIT License

Copyright (c) 2021 Deepgram Devs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License

Copyright (c) 2021 Deepgram Devs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

42 changes: 42 additions & 0 deletions cmd/analyze/analyze.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2024 Deepgram CLI contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

package analyze

import (
"fmt"

"github.com/spf13/cobra"

"github.com/deepgram-devs/deepgram-cli/cmd"
)

// analyzeCmd represents the analyze command
var analyzeCmd = &cobra.Command{
Use: "analyze",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("analyze called")
},
}

func init() {
cmd.RootCmd.AddCommand(analyzeCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// analyzeCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// analyzeCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
51 changes: 51 additions & 0 deletions cmd/listen/listen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2024 Deepgram CLI contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

package listen

import (
"fmt"

"github.com/spf13/cobra"

"github.com/deepgram-devs/deepgram-cli/cmd"
rest "github.com/deepgram-devs/deepgram-cli/cmd/listen/rest"
)

// listenCmd represents the listen command

Check failure on line 16 in cmd/listen/listen.go

View workflow job for this annotation

GitHub Actions / Change to Main/Release Branch

ST1022: comment on exported var ListenCmd should be of the form "ListenCmd ..." (stylecheck)
var ListenCmd = &cobra.Command{
Use: "listen",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("listen (Speech-to-Text) called")
fmt.Println("Available subcommands:")
if len(args) == 0 {
for _, subCmd := range cmd.Commands() {
fmt.Printf("- %s: %s\n", subCmd.Use, subCmd.Short)
}
}
},
}

func init() {
ListenCmd.AddCommand(rest.SttRestCmd)

cmd.RootCmd.AddCommand(ListenCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// listenCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// listenCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
27 changes: 27 additions & 0 deletions cmd/listen/rest/rest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2024 Deepgram CLI contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

package rest

import (
"fmt"

"github.com/spf13/cobra"
)

// sttRestCmd represents the sttRest command

Check failure on line 13 in cmd/listen/rest/rest.go

View workflow job for this annotation

GitHub Actions / Change to Main/Release Branch

ST1022: comment on exported var SttRestCmd should be of the form "SttRestCmd ..." (stylecheck)
var SttRestCmd = &cobra.Command{
Use: "rest",
Aliases: []string{"sttrest", "stt-rest", "speech-to-text-rest"},
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Speech-to-Text Rest called")
},
}
42 changes: 42 additions & 0 deletions cmd/manage/manage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2024 Deepgram CLI contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

package manage

import (
"fmt"

"github.com/spf13/cobra"

"github.com/deepgram-devs/deepgram-cli/cmd"
)

// manageCmd represents the manage command
var manageCmd = &cobra.Command{
Use: "manage",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("manage called")
},
}

func init() {
cmd.RootCmd.AddCommand(manageCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// manageCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// manageCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
47 changes: 47 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2024 Deepgram CLI contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

package cmd

import (
"os"

"github.com/spf13/cobra"
)

// rootCmd represents the base command when called without any subcommands

Check failure on line 13 in cmd/root.go

View workflow job for this annotation

GitHub Actions / Change to Main/Release Branch

ST1022: comment on exported var RootCmd should be of the form "RootCmd ..." (stylecheck)
var RootCmd = &cobra.Command{
Use: "cli",
Short: "A brief description of your application",
Long: `A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
err := RootCmd.Execute()
if err != nil {
os.Exit(1)
}
}

func init() {
// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.

// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cli.yaml)")

Check failure on line 42 in cmd/root.go

View workflow job for this annotation

GitHub Actions / Change to Main/Release Branch

commentedOutCode: may want to remove commented-out code (gocritic)

// Cobra also supports local flags, which will only run
// when this action is called directly.
RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
43 changes: 43 additions & 0 deletions cmd/selfhosted/selfHosted.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2024 Deepgram CLI contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

package selfhosted

import (
"fmt"

"github.com/spf13/cobra"

"github.com/deepgram-devs/deepgram-cli/cmd"
)

// selfHostedCmd represents the selfHosted command
var selfHostedCmd = &cobra.Command{
Use: "selfhosted",
Aliases: []string{"sh"},
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("selfHosted called")
},
}

func init() {
cmd.RootCmd.AddCommand(selfHostedCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// selfHostedCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// selfHostedCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
27 changes: 27 additions & 0 deletions cmd/speak/rest/rest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2024 Deepgram CLI contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

package rest

import (
"fmt"

"github.com/spf13/cobra"
)

// ttsRestCmd represents the ttsRest command

Check failure on line 13 in cmd/speak/rest/rest.go

View workflow job for this annotation

GitHub Actions / Change to Main/Release Branch

ST1022: comment on exported var TtsRestCmd should be of the form "TtsRestCmd ..." (stylecheck)
var TtsRestCmd = &cobra.Command{
Use: "rest",
Aliases: []string{"ttsrest", "tts-rest", "text-to-speech-rest"},
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Text-to-Speech REST called")
},
}
51 changes: 51 additions & 0 deletions cmd/speak/speak.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2024 Deepgram CLI contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

package speak

import (
"fmt"

"github.com/spf13/cobra"

"github.com/deepgram-devs/deepgram-cli/cmd"
"github.com/deepgram-devs/deepgram-cli/cmd/speak/rest"
)

// speakCmd represents the speak command

Check failure on line 16 in cmd/speak/speak.go

View workflow job for this annotation

GitHub Actions / Change to Main/Release Branch

ST1022: comment on exported var SpeakCmd should be of the form "SpeakCmd ..." (stylecheck)
var SpeakCmd = &cobra.Command{
Use: "speak",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("speak (Text-to-Speech) called")
fmt.Println("Available subcommands:")
if len(args) == 0 {
for _, subCmd := range cmd.Commands() {
fmt.Printf("- %s: %s\n", subCmd.Use, subCmd.Short)
}
}
},
}

func init() {
SpeakCmd.AddCommand(rest.TtsRestCmd)

cmd.RootCmd.AddCommand(SpeakCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// speakCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// speakCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/deepgram-devs/deepgram-cli

go 1.19

require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)
Loading

0 comments on commit 8e69fd5

Please sign in to comment.