summaryrefslogtreecommitdiff
path: root/crocc.go
diff options
context:
space:
mode:
authorNicolas Paul <n@nc0.fr>2023-04-25 17:39:02 +0200
committerNicolas Paul <n@nc0.fr>2023-04-25 17:39:02 +0200
commit1ab9ba20b482271d27456d6d52c124991278a299 (patch)
treedc8f8af8ca94b31b9e9e6cd95e86fd709c95f52b /crocc.go
parent12d086bf4a0dc9422ccbb3ef7b38625e4cc98d89 (diff)
Add Makefile
Allows inserting build information variables at compile time
Diffstat (limited to 'crocc.go')
-rw-r--r--crocc.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/crocc.go b/crocc.go
index 7be6806..59f1c7d 100644
--- a/crocc.go
+++ b/crocc.go
@@ -8,6 +8,7 @@ package main /* import "go.nc0.fr/crocc" */
import (
"flag"
"log"
+ "runtime"
)
var (
@@ -16,7 +17,7 @@ var (
sitemap = flag.Bool("sitemap", false, "generate sitemap.xml")
generateHidden = flag.Bool("hidden", false, "generate hidden pages")
verbose = flag.Bool("v", false, "verbose output")
- version = flag.Bool("version", false, "print version and exit")
+ printVersion = flag.Bool("version", false, "print version and exit")
)
const usage string = `crocc is a simple Markdown-based static site generator.
@@ -31,7 +32,11 @@ Usage:
Options:`
-const Version string = "1.0.0"
+// Set at compilation time
+var (
+ version string
+ date string
+)
func init() {
flag.Usage = func() {
@@ -43,8 +48,11 @@ func init() {
func main() {
flag.Parse()
- if *version {
- log.Printf("crocc v%s\n", Version)
+ log.SetFlags(0)
+
+ if *printVersion {
+ log.Printf("crocc version %s %s/%s %s date %s",
+ version, runtime.GOOS, runtime.GOARCH, runtime.Compiler, date)
return
}
}