@@ -16,23 +16,26 @@ import (
16
16
"text/template"
17
17
)
18
18
19
+ const version string = "1.0.2"
20
+
19
21
var (
20
- broker string
21
- specfile string
22
- protocol string
23
- mechanism string
24
- username string
25
- password string
26
- verbose bool
27
- isYAML bool
28
- isJSON bool
29
- actionApply bool
30
- actionDump bool
31
- actionHelp bool
32
- errorStop bool
33
- isTemplate bool
34
- missingOk bool
35
- varFlags arrFlags
22
+ broker string
23
+ specfile string
24
+ protocol string
25
+ mechanism string
26
+ username string
27
+ password string
28
+ verbose bool
29
+ isYAML bool
30
+ isJSON bool
31
+ actionApply bool
32
+ actionDump bool
33
+ actionHelp bool
34
+ actionVersion bool
35
+ errorStop bool
36
+ isTemplate bool
37
+ missingOk bool
38
+ varFlags arrFlags
36
39
)
37
40
38
41
type arrFlags []string
@@ -118,6 +121,8 @@ func main() {
118
121
}
119
122
} else if actionHelp {
120
123
usage ()
124
+ } else if actionVersion {
125
+ printVersion ()
121
126
}
122
127
}
123
128
@@ -764,6 +769,7 @@ func validateFlags() {
764
769
flag .BoolVar (& actionApply , "apply" , false , "Apply spec-file to the broker, create all entities that do not exist there; this is the default action" )
765
770
flag .BoolVar (& actionDump , "dump" , false , "Dump broker entities in YAML (default) or JSON format to stdout or to a file if --spec option is defined" )
766
771
flag .BoolVar (& actionHelp , "help" , false , "Print usage" )
772
+ flag .BoolVar (& actionVersion , "version" , false , "Show version" )
767
773
flag .BoolVar (& isYAML , "yaml" , false , "Spec-file is in YAML format (will try to detect format if none of --yaml or --json is set)" )
768
774
flag .BoolVar (& isJSON , "json" , false , "Spec-file is in JSON format (will try to detect format if none of --yaml or --json is set)" )
769
775
flag .BoolVar (& errorStop , "stop-on-error" , false , "Exit on first occurred error" )
@@ -779,8 +785,8 @@ func validateFlags() {
779
785
protocol = strings .ToLower (protocol )
780
786
mechanism = strings .ToLower (mechanism )
781
787
782
- if ! actionApply && ! actionDump && ! actionHelp {
783
- fmt .Println ("Please define one of the actions: --dump, --apply, --help" )
788
+ if ! actionApply && ! actionDump && ! actionHelp && ! actionVersion {
789
+ fmt .Println ("Please define one of the actions: --dump, --apply, --help, --version " )
784
790
os .Exit (1 )
785
791
}
786
792
if actionApply && actionDump {
@@ -814,6 +820,11 @@ func validateFlags() {
814
820
}
815
821
}
816
822
823
+ func printVersion () error {
824
+ fmt .Println (version )
825
+ return nil
826
+ }
827
+
817
828
func usage () {
818
829
usage := `Manage Kafka cluster resources (topics and ACLs)
819
830
Usage: %s <action> [<options>] [<broker connection options>]
@@ -824,6 +835,7 @@ Usage: %s <action> [<options>] [<broker connection options>]
824
835
See also --json and --yaml options
825
836
--apply Idempotently align cluster resources with the spec manifest
826
837
See also --spec, --json and --yaml options
838
+ --version Show version
827
839
----------------
828
840
Options
829
841
--spec A path to manifest (specification file) to be used
0 commit comments