@@ -85,13 +85,15 @@ Specifying the full paths.
8585`
8686)
8787
88- func fmtTxt (src string , appName string , version string ) string {
89- return strings .ReplaceAll (strings .ReplaceAll (helpText , "{app_name}" , appName ), "{version}" , version )
90- }
91-
9288func main () {
89+
9390 // command line name and options support
9491 appName := path .Base (os .Args [0 ])
92+ version := datatools .Version
93+ license := datatools .LicenseText
94+ releaseDate := datatools .ReleaseDate
95+ releaseHash := datatools .ReleaseHash
96+
9597 showHelp , showVersion , showLicense := false , false , false
9698 // Setup to parse command line
9799 flag .BoolVar (& showHelp , "help" , false , "display help" )
@@ -101,17 +103,21 @@ func main() {
101103
102104 args := flag .Args ()
103105
106+ //in := os.Stdin
107+ out := os .Stdout
108+ eout := os .Stderr
109+
104110 // Process options and run report
105111 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 ))
107113 os .Exit (0 )
108114 }
109115 if showLicense {
110- fmt .Fprintf (os . Stdout , "%s\n " , fmtTxt ( datatools . LicenseText , appName , datatools . Version ) )
116+ fmt .Fprintf (out , "%s\n " , license )
111117 os .Exit (0 )
112118 }
113119 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 )
115121 os .Exit (0 )
116122 }
117123 codemeta , citation := "codemeta.json" , "CITATION.cff"
@@ -120,12 +126,12 @@ func main() {
120126 } else if len (args ) == 1 {
121127 codemeta = args [0 ]
122128 } 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 , " " ))
124130 os .Exit (1 )
125131 }
126132 err := datatools .CodemetaToCitationCff (codemeta , citation )
127133 if err != nil {
128- fmt .Fprintf (os . Stderr , "ERROR: %s\n " , err )
134+ fmt .Fprintf (eout , "ERROR: %s\n " , err )
129135 os .Exit (1 )
130136 }
131137}
0 commit comments