示例#1
0
文件: main.go 项目: anarcher/envconf
func init() {

	flag.Usage = func() {
		fmt.Printf("Usage: envconv [options] file [files...]\n\n")
		flag.PrintDefaults()
	}

	version := flag.Bool("v", false, "Prints current version")

	flag.Parse()

	if *version {
		fmt.Println("envconf version " + VERSION)
		os.Exit(0)
	}

	templateFuncMap = template.FuncMap{
		"default": func(args ...string) string {
			defer recovery()
			if len(args) <= 0 {
				return ""
			}
			return args[len(args)-1]
		},
		"in": func(arg string, slice []string) bool {
			defer recovery()
			for _, i := range slice {
				if arg == i {
					return true
				}
			}
			return false
		},
	}
}
示例#2
0
文件: main.go 项目: carriercomm/puro
import (
	"crypto/tls"
	"net"
	"net/http"
	"strings"

	"github.com/Sirupsen/logrus"
	"github.com/coreos/go-etcd/etcd"
	"github.com/namsral/flag"
)

var (
	configFlag       = flag.String("config", "", "Config file to read")                  // Enable config file cuntionality
	logFormatterType = flag.String("log_formatter_type", "text", "Log formatter to use") // Logrus log formatter
	logForceColors   = flag.Bool("log_force_colors", false, "Force colored log output?") // Logrus force colors
	etcdAddress      = flag.String("etcd_address", "", "Address of the etcd server to use")
	etcdPath         = flag.String("etcd_path", "", "Prefix of the etcd directory, no slash near the end")
	sessionCacheSize = flag.Int("session_cache_size", 64, "Size of the LRU client session cache")

	rawBind = flag.String("raw_bind", "0.0.0.0:80", "Address used for the HTTP server")
	tlsBind = flag.String("tls_bind", "0.0.0.0:443", "Address used for the HTTPS server")
)

var (
	tlsConfig *tls.Config
)

func main() {
	// Parse the flags
	flag.Parse()
示例#3
0
	"github.com/Zenithar/goproject/cmd/server/system"
	"github.com/Zenithar/goproject/version"

	"github.com/Sirupsen/logrus"
	"github.com/namsral/flag"
	"github.com/zenazn/goji/graceful"
)

var (
	// Enable namsral/flag logality
	configFlag = flag.String("config", "", "config file to load")

	// General flags
	bindAddress      = flag.String("bind", ":5000", "Network address used to bind")
	logFormatterType = flag.String("log", "text", "Log formatter type. Either \"json\" or \"text\"")
	forceColors      = flag.Bool("force_colors", false, "Force colored prompt?")
	ravenDSN         = flag.String("raven_dsn", "", "Defines the sentry endpoint dsn")

	databaseDriver    = flag.String("db_driver", "mongodb", "Specify the database to use (mongodb, rethinkdb)")
	databaseHost      = flag.String("db_host", "localhost:27017", "Database hosts, split by ',' to add several hosts")
	databaseNamespace = flag.String("db_namespace", "hammurapi", "Select the database")
	databaseUser      = flag.String("db_user", "", "Database user")
	databasePassword  = flag.String("db_password", "", "Database user password")

	memcachedHosts = flag.String("memcached_hosts", "", "Memcached servers for cache (ex: 127.0.0.1:11211)")
	redisHost      = flag.String("redis_host", "", "Redis server for cache")
)

func main() {
	// Parse the flags
	flag.Parse()
示例#4
0
package main

import (
	"strings"

	"github.com/Sirupsen/logrus"
	r "github.com/dancannon/gorethink"
	"github.com/namsral/flag"
)

var (
	configFlag       = flag.String("config", "", "Config file to read")
	logFormatterType = flag.String("log_formatter", "text", "Log formatter type")
	logForceColors   = flag.Bool("log_force_colors", false, "Force colored prompt?")

	apiURL = flag.String("api_url", "https://api.lavaboom.com", "Path to the Lavaboom API")

	nsqdAddress       = flag.String("nsqd_address", "127.0.0.1:4150", "Address of the NSQ server")
	lookupdAddress    = flag.String("lookupd_address", "127.0.0.1:4160", "Address of the nsqlookupd server")
	rethinkdbAddress  = flag.String("rethinkdb_address", "127.0.0.1:28015", "Address of the RethinkDB server")
	rethinkdbDatabase = flag.String("rethinkdb_database", "lavabot", "RethinkDB database to use")

	enableHub    = flag.Bool("enable_hub", true, "Enable hub module")
	enableSender = flag.Bool("enable_sender", true, "Enable sender module")

	welcomeName           = flag.String("welcome_name", "welcome", "Name of the welcome template to use")
	welcomeVersion        = flag.String("welcome_version", "1.0.0", "Version of the welcome template to use")
	gettingStartedName    = flag.String("getting_name", "getting", "Name of the getting started template to use")
	gettingStartedVersion = flag.String("getting_version", "1.0.0", "Version of the getting started template to use")
	securityName          = flag.String("security_name", "security", "Name of the security info template to use")
	securityVersion       = flag.String("security_version", "1.0.0", "Version of the security info template to use")
示例#5
0
文件: main.go 项目: Xe/betterbot
import (
	"runtime"
	"strings"

	"github.com/Xe/betterbot-common"
	"github.com/Xe/uuid"
	"github.com/namsral/flag"
	"github.com/thoj/go-ircevent"
)

var (
	uplink *common.Uplink

	config       = flag.String("config", "", "configuration file")
	ircServer    = flag.String("irc-server", "ircd:6667", "which IRC server to connect to")
	ircServerSSL = flag.Bool("irc-server-ssl", false, "connect over ssl?")
	ircChannels  = flag.String("irc-channels", "#betterbot", "which IRC channels to join on connect")
	ircNick      = flag.String("irc-nick", "betterbot", "bot nickname")
	ircUser      = flag.String("irc-user", "betterbot", "irc username")
	ircPassword  = flag.String("irc-password", "hunter2", "password on connection (default *******)")
	nsPass       = flag.String("nickserv-pass", "hunter2", "which password to use for NickServ (default *******)")
)

func main() {
	flag.Parse()

	conn, err := common.Connect()
	if err != nil {
		panic(err)
	}
	uplink = conn
示例#6
0
文件: 3do.go 项目: 3onyc/3do
	"github.com/GeertJohan/go.rice"
	"github.com/gorilla/mux"
	"github.com/jmoiron/sqlx"
	"github.com/namsral/flag"
	"log"
	"net/http"
	"net/http/httputil"
	"net/url"

	_ "github.com/mattn/go-sqlite3"
)

var (
	CONFIG_FILE  = flag.String("config", "", "Path to config file")
	WEB_PORT     = flag.Uint64("port", 8080, "Port for the webserver to listen on")
	DEBUG        = flag.Bool("debug", false, "Debug mode")
	DB_SEED      = flag.Bool("db-seed", false, "Seed the DB with initial values")
	DB_URI       = flag.String("db-uri", ":memory:", "Path/URI to store DB at")
	FRONTEND_URL = flag.String(
		"frontend-url",
		"http://localhost:4200",
		"In debug mode reverse proxy is used instead of embedded files",
	)
)

func initDB() *sqlx.DB {
	log.Printf("Initialising database at %s...\n", *DB_URI)
	db := sqlx.MustConnect("sqlite3", *DB_URI)
	appinit.CreateDBSchema(db)

	return db