@@ -19,6 +19,7 @@ import (
19
19
"io/ioutil"
20
20
"os"
21
21
"path"
22
+ "strings"
22
23
23
24
"gopkg.in/yaml.v3"
24
25
@@ -30,7 +31,7 @@ import (
30
31
)
31
32
32
33
var (
33
- input , output , outputType , configFile string
34
+ input , output , outputType , outputFileType , configFile string
34
35
)
35
36
36
37
// GenerateCmd represents the base command when called without any subcommands
@@ -64,7 +65,14 @@ var GenerateCmd = &cobra.Command{
64
65
return err
65
66
}
66
67
67
- file := hierarchy .GeneratePropertiesFile (resources )
68
+ var file string
69
+ if strings .ToLower (outputFileType ) == "" || strings .ToLower (outputFileType ) == "env" {
70
+ file = hierarchy .GeneratePropertiesFile (resources )
71
+ }
72
+ if strings .ToLower (outputFileType ) == "js" || strings .ToLower (outputFileType ) == "javascript" {
73
+ file = hierarchy .GenerateJsPropertiesFile (resources )
74
+ }
75
+
68
76
if outputType == "stdout" {
69
77
fmt .Println (file )
70
78
} else {
@@ -89,6 +97,8 @@ var GenerateCmd = &cobra.Command{
89
97
func init () {
90
98
GenerateCmd .Flags ().StringVarP (& input , "input" , "i" , "-" , "input of yaml dump (default '-' is stdin)" )
91
99
GenerateCmd .Flags ().StringVarP (& configFile , "config" , "c" , "config.yml" , "path to config file containing hierarchy" )
92
- GenerateCmd .Flags ().StringVarP (& outputType , "output-type" , "" , "stdout" , "type of output: can be one of stdout, properties" )
100
+ GenerateCmd .Flags ().StringVarP (& outputType , "output-type" , "" , "stdout" , "type of output: can be one of 'stdout', 'file'" )
101
+ GenerateCmd .Flags ().StringVarP (& outputFileType , "output-filetype" , "" , "env" , "when output is a file: can be one of 'env', 'js/javascript'" )
93
102
GenerateCmd .Flags ().StringVarP (& output , "output-path" , "" , "properties/{{.name}}.properties" , "output path" )
103
+
94
104
}
0 commit comments