aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2017-10-21 09:16:43 -0700
committerAdam Mathes <adam@trenchant.org>2017-10-21 09:16:43 -0700
commitf866d14f0f453110ca5119aced5f22f45e529723 (patch)
treeca47014ede301b2b95e4ae10cc6ea846114ddfcd
parent59a506dea038f693414efed5f1edaa65a09a48e3 (diff)
downloadsnkt-f866d14f0f453110ca5119aced5f22f45e529723.tar.gz
snkt-f866d14f0f453110ca5119aced5f22f45e529723.tar.bz2
snkt-f866d14f0f453110ca5119aced5f22f45e529723.zip
Switch from go standard lib flag lib to github.com/ogier/pflag
For more UNIXey/POSIXey command line, ie $ snkt --build --preview $ snkt -bp
-rw-r--r--main.go31
1 files changed, 13 insertions, 18 deletions
diff --git a/main.go b/main.go
index 24a26d8..5536742 100644
--- a/main.go
+++ b/main.go
@@ -4,48 +4,43 @@ snkt is a static site generator for simple blog-like sites with a focus on simpl
package main
import (
- "flag"
"adammathes.com/snkt/config"
"adammathes.com/snkt/render"
"adammathes.com/snkt/site"
- "adammathes.com/snkt/web"
"adammathes.com/snkt/vlog"
+ "adammathes.com/snkt/web"
"fmt"
+ flag "github.com/ogier/pflag"
)
func main() {
var configFile, init_dir string
var build, preview, version, verbose, help bool
-
- flag.StringVar(&configFile, "c", "config.yml", "`configuration` file")
- flag.StringVar(&init_dir, "init", "", "initialize new site at `directory`")
- flag.BoolVar(&build, "b", false, "build site")
- flag.BoolVar(&preview, "p", false, "preview site with local HTTP server")
- flag.BoolVar(&version, "v", false, "print version number")
- flag.BoolVar(&help, "h", false, "help")
- flag.BoolVar(&verbose, "verbose", false, "log actions during build")
+
+ flag.StringVarP(&configFile, "config", "c", "config.yml", "`configuration` file")
+ flag.StringVarP(&init_dir, "init", "i", "", "initialize new site at `directory`")
+ flag.BoolVarP(&build, "build", "b", false, "build site")
+ flag.BoolVarP(&preview, "preview", "p", false, "preview site with local HTTP server")
+ flag.BoolVarP(&help, "help", "h", false, "print help message")
+ flag.BoolVarP(&verbose, "verbose", "v", false, "log actions during build to STDOUT")
flag.Parse()
- if !help && !build && !preview && !version && init_dir=="" {
+ if !help && !build && !preview && !version && init_dir == "" {
flag.Usage()
return
}
- if(init_dir != "") {
+ if init_dir != "" {
fmt.Printf("initializing new site in %s\n", init_dir)
site.Init(init_dir)
return
}
- if(version) {
- fmt.Printf("0.1 alpha\n")
- return
- }
- if(help) {
+ if help {
fmt.Printf("please see README.md\n")
return
}
config.Init(configFile)
- if(verbose) {
+ if verbose {
config.Config.Verbose = true
}