first commit
This commit is contained in:
29
cli/cmd/cli.go
Normal file
29
cli/cmd/cli.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
RootCmd = &cobra.Command{
|
||||
Use: "acli",
|
||||
Short: "Интерфейс командной строки",
|
||||
CompletionOptions: cobra.CompletionOptions{
|
||||
HiddenDefaultCmd: true,
|
||||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if len(args) == 0 {
|
||||
cmd.Help()
|
||||
os.Exit(0)
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func Execute() {
|
||||
if err := RootCmd.Execute(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
26
cli/cmd/list.go
Normal file
26
cli/cmd/list.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"awesome_cli/internal/service"
|
||||
"awesome_cli/internal/views"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
RootCmd.AddCommand(list())
|
||||
}
|
||||
|
||||
func list() *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
Use: "list",
|
||||
Aliases: []string{"l"},
|
||||
Short: "Вывод списка",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
vms := service.VMService().List()
|
||||
views.List(vms)
|
||||
},
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
Reference in New Issue
Block a user