@@ -85,13 +85,15 @@ Specifying the full paths.
85
85
`
86
86
)
87
87
88
- func fmtTxt (src string , appName string , version string ) string {
89
- return strings .ReplaceAll (strings .ReplaceAll (helpText , "{app_name}" , appName ), "{version}" , version )
90
- }
91
-
92
88
func main () {
89
+
93
90
// command line name and options support
94
91
appName := path .Base (os .Args [0 ])
92
+ version := datatools .Version
93
+ license := datatools .LicenseText
94
+ releaseDate := datatools .ReleaseDate
95
+ releaseHash := datatools .ReleaseHash
96
+
95
97
showHelp , showVersion , showLicense := false , false , false
96
98
// Setup to parse command line
97
99
flag .BoolVar (& showHelp , "help" , false , "display help" )
@@ -101,17 +103,21 @@ func main() {
101
103
102
104
args := flag .Args ()
103
105
106
+ //in := os.Stdin
107
+ out := os .Stdout
108
+ eout := os .Stderr
109
+
104
110
// Process options and run report
105
111
if showHelp {
106
- fmt .Fprintf (os . Stdout , "%s\n " , fmtTxt (helpText , appName , datatools . Version ))
112
+ fmt .Fprintf (out , "%s\n " , datatools . FmtHelp (helpText , appName , version , releaseDate , releaseHash ))
107
113
os .Exit (0 )
108
114
}
109
115
if showLicense {
110
- fmt .Fprintf (os . Stdout , "%s\n " , fmtTxt ( datatools . LicenseText , appName , datatools . Version ) )
116
+ fmt .Fprintf (out , "%s\n " , license )
111
117
os .Exit (0 )
112
118
}
113
119
if showVersion {
114
- fmt .Printf ( "datatools, %s v%s \n " , appName , datatools . Version )
120
+ fmt .Fprintf ( out , "datatools, %s %s %s \n " , appName , version , releaseHash )
115
121
os .Exit (0 )
116
122
}
117
123
codemeta , citation := "codemeta.json" , "CITATION.cff"
@@ -120,12 +126,12 @@ func main() {
120
126
} else if len (args ) == 1 {
121
127
codemeta = args [0 ]
122
128
} else if len (args ) != 0 {
123
- fmt .Fprintf (os . Stderr , "Unexpected parameters: %q\n " , strings .Join (os .Args , " " ))
129
+ fmt .Fprintf (eout , "Unexpected parameters: %q\n " , strings .Join (os .Args , " " ))
124
130
os .Exit (1 )
125
131
}
126
132
err := datatools .CodemetaToCitationCff (codemeta , citation )
127
133
if err != nil {
128
- fmt .Fprintf (os . Stderr , "ERROR: %s\n " , err )
134
+ fmt .Fprintf (eout , "ERROR: %s\n " , err )
129
135
os .Exit (1 )
130
136
}
131
137
}
0 commit comments