summaryrefslogtreecommitdiffstats
path: root/fern.go
diff options
context:
space:
mode:
Diffstat (limited to 'fern.go')
-rw-r--r--fern.go32
1 files changed, 30 insertions, 2 deletions
diff --git a/fern.go b/fern.go
index 8b2b1ac..70e79fb 100644
--- a/fern.go
+++ b/fern.go
@@ -33,13 +33,17 @@
// You may download an example config file for fern from
// https://ricketyspace.net/fern/fern.json
//
-// fern does not take any arguments, to run it just do:
+// Run fern with:
//
-// $ fern
+// $ fern -run
//
+// To print fern's version, do:
+//
+// $ fern -version
package main
import (
+ "flag"
"fmt"
"os"
@@ -48,9 +52,14 @@ import (
"ricketyspace.net/fern/state"
)
+const version = "0.3.0"
+
var fConf *config.FernConfig
var pState *state.ProcessState
+var vFlag *bool
+var rFlag *bool
+
func init() {
var err error
@@ -70,6 +79,25 @@ func init() {
fmt.Printf("Error: %v\n", err.Error())
os.Exit(1)
}
+
+ // Parse args.
+ vFlag = flag.Bool("version", false, "Print version")
+ rFlag = flag.Bool("run", false, "Run fern")
+ flag.Parse()
+
+ if *vFlag {
+ fmt.Printf("%s\n", version)
+ os.Exit(0)
+ }
+ if !*rFlag {
+ printUsage(2)
+ }
+}
+
+func printUsage(exit int) {
+ fmt.Printf("fern [ -run | -version ]\n")
+ flag.PrintDefaults()
+ os.Exit(exit)
}
func main() {