File: test.go

package info (click to toggle)
golang-github-ivanpirog-coloredcobra 1.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 108 kB
  • sloc: makefile: 4
file content (27 lines) | stat: -rw-r--r-- 557 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package cmd

import (
	"fmt"

	"github.com/spf13/cobra"
)

var (
	Host string
	Port int
)

var helloCmd = &cobra.Command{
	Use:   "test",
	Short: "Test command for clarity",
	Long:  `This command prints a simple message "Hello world!"`,
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("Hello, world!")
	},
}

func init() {
	helloCmd.Flags().StringVarP(&Host, "host", "s", "localhost", "A host for the Hello World server")
	helloCmd.Flags().IntVarP(&Port, "port", "p", 8080, "A port for the Hello World server")
	rootCmd.AddCommand(helloCmd)
}