Esempio n. 1
0
func (cm *ConfigManager) parseFlags() {
	pflag.StringVarP(&cm.Flags.ConfigFile, "configfile", "c", DefaultConfigFile, "Path to config")
	pflag.StringVarP(&cm.Flags.DestHost, "dest-host", "d", "", "Destination syslog hostname or IP")
	pflag.IntVarP(&cm.Flags.DestPort, "dest-port", "p", 0, "Destination syslog port")
	if utils.CanDaemonize {
		pflag.BoolVarP(&cm.Flags.NoDaemonize, "no-detach", "D", false, "Don't daemonize and detach from the terminal")
	} else {
		cm.Flags.NoDaemonize = true
	}
	pflag.StringVarP(&cm.Flags.Facility, "facility", "f", "user", "Facility")
	pflag.StringVar(&cm.Flags.Hostname, "hostname", "", "Local hostname to send from")
	pflag.StringVar(&cm.Flags.PidFile, "pid-file", "", "Location of the PID file")
	// --parse-syslog
	pflag.StringVarP(&cm.Flags.Severity, "severity", "s", "notice", "Severity")
	// --strip-color
	pflag.BoolVar(&cm.Flags.UseTCP, "tcp", false, "Connect via TCP (no TLS)")
	pflag.BoolVar(&cm.Flags.UseTLS, "tls", false, "Connect via TCP with TLS")
	pflag.BoolVar(&cm.Flags.Poll, "poll", false, "Detect changes by polling instead of inotify")
	pflag.Var(&cm.Flags.RefreshInterval, "new-file-check-interval", "How often to check for new files")
	_ = pflag.Bool("no-eventmachine-tail", false, "No action, provided for backwards compatibility")
	_ = pflag.Bool("eventmachine-tail", false, "No action, provided for backwards compatibility")
	pflag.StringVar(&cm.Flags.DebugLogFile, "debug-log-cfg", "", "the debug log file")
	pflag.StringVar(&cm.Flags.LogLevels, "log", "<root>=INFO", "\"logging configuration <root>=INFO;first=TRACE\"")
	pflag.Parse()
	cm.FlagFiles = pflag.Args()
}
Esempio n. 2
0
func Execute() {
	flag.Usage = printHelp

	doValidate := flag.Bool("validate", false, "Validates that the specified config file is valid.")
	doVersion := flag.Bool("version", false, "Prints the version information about the Frosty backup utility.")

	flag.Parse()

	switch {
	case *doValidate:
		validate(os.Args[1])
	case *doVersion:
		printVersion()
	default:
		backup(os.Args[1])
	}
}
Esempio n. 3
0
File: main.go Progetto: felipeg48/jp
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: jp [file]\n")
		flag.PrintDefaults()
	}

	isTerminal := terminal.IsTerminal(int(os.Stdout.Fd()))

	compact := flag.Bool("compact", false, "compact format")
	colors := flag.Bool("color", isTerminal, "colored format")

	flag.Parse()
	args := flag.Args()
	if len(args) < 1 {
		flag.Usage()
		os.Exit(2)
	}

	format := "pretty"
	if *compact {
		format = "compact"
	}
	if *colors {
		format += "16"
	}

	var fd *os.File
	var e error
	if args[0] == "-" {
		fd = os.Stdin
	} else {
		fd, e = os.Open(args[0])
		if e != nil {
			fmt.Fprintln(os.Stderr, "Error:", e)
			os.Exit(1)
		}
	}

	e = jp.Expand(fd, os.Stdout, format)
	if e != nil {
		fmt.Fprintln(os.Stderr, "Error:", e)
		os.Exit(1)
	}
}
Esempio n. 4
0
// Run parses the command line options in accordance with TODO(url) and runs the appropriate steps.
func (j *Job) Run() {
	var runMapper = flag.Bool("mapper", false, "Run the mapper")
	var runReducer = flag.Bool("reducer", false, "Run the mapper")
	var printSteps = flag.Bool("steps", false, "Print step descriptions")
	var stepNum = flag.Uint("step-num", 0, "Step number")

	flag.Parse()

	if *runMapper {
		j.Steps[*stepNum].runMapper()
	} else if *runReducer {
		err := j.Steps[*stepNum].runReducer()
		if err != nil && err != io.EOF {
			panic(err)
		}
	} else if *printSteps {
		j.printSteps()
	}
	return
}
Esempio n. 5
0
	"log"
	"os"
	"os/exec"
	"path/filepath"
	"strings"
)

const APP_VERSION = "0.1"
const inputDelim = '\n'

var fileCount int = 0
var fileBytesRead int = 0
var fileBytesWritten int = 0

// The flag package provides a default help printer via -h switch
var versionFlag *bool = flag.Bool("v", false, "Print the version number.")

// Files
var FileSep = string(os.PathSeparator)
var LocalPkgs = []byte{'p', 'k', 'g', 's', '/'}

func main() {
	flag.Parse() // Scan the arguments list
	fmt.Fprintln(os.Stdout, LOGO)
	if *versionFlag {
		fmt.Println("Version:", APP_VERSION)
		return
	}
	cmd := flag.Arg(0)
	name := flag.Arg(1)
	switch cmd {
Esempio n. 6
0
Written by Eric Lagergren
Inspired by David MacKenzie.`
	HELP = `Usage: tty [OPTION]...
Print the file name of the terminal connected to standard input.

  -s, --silent, --quiet   print nothing, only return an exit status
      --help     display this help and exit
      --version  output version information and exit

Report uname bugs to [email protected]
Go coreutils home page: <https://www.github.com/EricLagergren/go-coreutils/>`
)

var (
	version = flag.Bool("version", false, "print version")
	quiet1  = flag.BoolP("silent", "s", false, "no output")
	quiet2  = flag.Bool("quiet", false, "no output")
)

func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "%s\n", HELP)
		return
	}
	flag.Parse()

	if *version {
		fmt.Printf("%s\n", VERSION)
		return
	}
Esempio n. 7
0
	sparseNever
	sparseAuto
	sparseAlways
)

// backup enum
const (
	noBackups = iota
	simpleBackups
	numberedExistingBackups
	numberedBackups
)

var (
	archive           = flag.BoolP("archive", "a", false, "")
	attrOnly          = flag.Bool("attributes-only", false, "")
	backup            = flag.String("backup", "", "")
	backup2           = flag.Bool("b", false, "")
	copyContents      = flag.Bool("copy-contents", false, "")
	ndrpl             = flag.Bool("d", false, "")
	dereference       = flag.BoolP("dereference", "L", false, "")
	force             = flag.BoolP("force", "f", false, "")
	hopt              = flag.Bool("H", false, "")
	interactive       = flag.BoolP("interactive", "i", false, "")
	link              = flag.BoolP("link", "l", false, "")
	noClobber         = flag.BoolP("no-clobber", "n", false, "")
	noDereference     = flag.BoolP("no-dereference", "P", false, "")
	noPreserve        = flag.String("no-preserve", "", "")
	noTargetDir       = flag.BoolP("no-target-directory", "T", false, "")
	oneFS             = flag.BoolP("one-file-system", "x", false, "")
	parents           = flag.Bool("parents", false, "")
Esempio n. 8
0
There is NO WARRANTY, to the extent permitted by law.

Written by Eric Lagergren`
)

var (
	dev = []byte("/dev/")
	bt  int32
)

var (
	all       = flag.BoolP("all", "a", false, "")
	boot      = flag.BoolP("boot", "b", false, "")
	dead      = flag.BoolP("dead", "d", false, "")
	heading   = flag.BoolP("heading", "H", false, "")
	ips       = flag.Bool("ips", false, "")
	login     = flag.BoolP("login", "l", false, "")
	cur       = flag.Bool("m", false, "")
	proc      = flag.BoolP("process", "p", false, "")
	count     = flag.BoolP("count", "q", false, "")
	rlvl      = flag.BoolP("runlevel", "r", false, "")
	short     = flag.BoolP("short", "s", false, "")
	clock     = flag.BoolP("time", "t", false, "")
	users     = flag.BoolP("users", "u", false, "")
	mesg      = flag.BoolP("mesg", "T", false, "")
	mesgTwo   = flag.BoolP("message", "w", false, "")
	mesgThree = flag.Bool("writable", false, "")
	doLookup  = flag.Bool("lookup", false, "")
	version   = flag.Bool("version", false, "")
)
Esempio n. 9
0
File: main.go Progetto: nsabine/hugo
	"github.com/mostafah/fsync"
	flag "github.com/ogier/pflag"
	"github.com/spf13/hugo/hugolib"
	"log"
	"net/http"
	"os"
	"path/filepath"
	"runtime/pprof"
	"sync"
	"time"
)

var (
	baseUrl     = flag.StringP("base-url", "b", "", "hostname (and path) to the root eg. http://spf13.com/")
	cfgfile     = flag.String("config", "", "config file (default is path/config.yaml|json|toml)")
	checkMode   = flag.Bool("check", false, "analyze content and provide feedback")
	draft       = flag.BoolP("build-drafts", "D", false, "include content marked as draft")
	help        = flag.BoolP("help", "h", false, "show this help")
	source      = flag.StringP("source", "s", "", "filesystem path to read files relative from")
	destination = flag.StringP("destination", "d", "", "filesystem path to write files to")
	verbose     = flag.BoolP("verbose", "v", false, "verbose output")
	version     = flag.Bool("version", false, "which version of hugo")
	cpuprofile  = flag.Int("profile", 0, "Number of times to create the site and profile it")
	watchMode   = flag.BoolP("watch", "w", false, "watch filesystem for changes and recreate as needed")
	server      = flag.BoolP("server", "S", false, "run a (very) simple web server")
	port        = flag.String("port", "1313", "port to run web server on, default :1313")
	uglyUrls    = flag.Bool("uglyurls", false, "use /filename.html instead of /filename/ ")
)

func usage() {
	PrintErr("usage: hugo [flags]", "")
Esempio n. 10
0
Written by Eric Lagergren <*****@*****.**>
`
)

var (
	all        = flag.BoolP("show-all", "A", false, "")
	blank      = flag.BoolP("number-nonblank", "b", false, "")
	npEnds     = flag.BoolP("ends", "e", false, "")
	ends       = flag.BoolP("show-ends", "E", false, "")
	number     = flag.BoolP("number", "n", false, "")
	squeeze    = flag.BoolP("squeeze-blank", "s", false, "")
	npTabs     = flag.BoolP("tabs", "t", false, "")
	tabs       = flag.BoolP("show-tabs", "T", false, "")
	nonPrint   = flag.BoolP("non-printing", "v", false, "")
	unbuffered = flag.BoolP("unbuffered", "u", false, "")
	version    = flag.Bool("version", false, "")

	totalNewline    int64
	showNonPrinting bool

	fatal = log.New(os.Stderr, "", 0)
	// fatal = log.New(os.Stderr, "", log.Lshortfile)
)

const Caret = '^'

var (
	MDash    = []byte("M-")
	HorizTab = []byte("^I")
	Delete   = []byte("^?")
Esempio n. 11
0
	log "maunium.net/go/maulogger"
	"maunium.net/go/mauth"
	"net/http"
	"os"
	"os/signal"
	"path/filepath"
	"strconv"
	"syscall"
)

const version = "2.1.0"

var debug = flag.BoolP("debug", "d", false, "Enable to print debug messages to stdout")
var confPath = flag.StringP("config", "c", "/etc/mis/config.json", "The path of the mauImageServer configuration file.")
var logPath = flag.StringP("logs", "l", "/var/log/mis", "The path of the mauImageServer configuration file.")
var disableSafeShutdown = flag.Bool("no-safe-shutdown", false, "Disable Interrupt/SIGTERM catching and handling.")

var config *data.Configuration
var database data.MISDatabase
var auth mauth.System

func main() {
	flag.Parse()

	if !*disableSafeShutdown {
		c := make(chan os.Signal, 1)
		signal.Notify(c, os.Interrupt, syscall.SIGTERM)
		go func() {
			<-c
			os.Stdout.Write([]byte("\n"))
			log.Infof("Shutting down mauImageServer...")
Esempio n. 12
0
	"encoding/json"
	"fmt"
	log "github.com/alecthomas/log4go"
	"github.com/alecthomas/tuplespace"
	"github.com/alecthomas/tuplespace/client"
	"github.com/ogier/pflag"
	"os"
	"runtime"
	"time"
)

var (
	serverFlag  = pflag.String("server", "http://127.0.0.1:2619/tuplespace/", "tuplespace server address")
	timeoutFlag = pflag.Duration("timeout", time.Second*60, "tuplespace operation timeout")
	copiesFlag  = pflag.Int("copies", 1, "number of copies of the tuple to send")
	silentFlag  = pflag.Bool("silent", false, "don't display received tuples")
)

func fatalf(f string, args ...interface{}) {
	fmt.Fprintf(os.Stderr, "error: "+f+"\n", args...)
	os.Exit(1)
}

func parseTuple(arg string) (tuple tuplespace.Tuple) {
	err := json.Unmarshal([]byte(arg), &tuple)
	if err != nil {
		fatalf("invalid tuple (%s)", err.Error())
	}
	return
}
Esempio n. 13
0
func main() {
	var err error

	log.Info(`Build 1.`)

	//============= Parse Command Line Flags ===================
	var UseStandaloneServer *bool = flag.Bool("server", false, `Launch as a standalone server.`)
	var IsDevEnv *bool = flag.Bool("dev", false, `Run in development mode.`)
	flag.Parse()
	//======================

	UserDataDir, err := malkovich.GetUserDataDirectory()
	log.Info(UserDataDir)

	var exeRoot string

	log.Info("start server...")

	UseSlackHook := false
	UseRequestLogger := true

	//log.SetLevel(log.PanicLevel)
	setupLogging(UseSlackHook)

	//=============  General Initialization ===================
	math_rand.Seed(time.Now().UTC().UnixNano())

	exeRoot, err = osext.ExecutableFolder()
	if err != nil {
		log.Fatalf("ERROR: %s", err.Error())
	} else {
		go log.Info("EXE Root: " + exeRoot)
	}

	UserDocRoot, err := malkovich.GetUserDocsDirectory()
	if err != nil {
		log.Fatalf("ERROR: User data directory not found. (%s)", err.Error())
		return
	}

	//=============  Router Initialization ===================
	router := mux.New()

	log.Infof("UserDocRoot = %s", UserDocRoot)

	commandsController := commands.New()
	commandsController.DocRoot = UserDocRoot
	router.POST("/api/v1/commands/pagefiles/:DocName/*filepath", commandsController.OpenFile)

	docServer := docs.New()
	docServer.DocRoot = UserDocRoot

	router.GET("/api/v1/frontpagedoc", docServer.GetFrontPageDocList)
	router.PUT("/api/v1/frontpagedoc/:name", docServer.CreateNewFrontPageDoc)
	router.GET("/api/v1/docs", docServer.GetDocList)
	router.GET("/api/v1/docs/:name/html", docServer.GetDocAsHtml)
	router.GET("/api/v1/docs/:name/md", docServer.GetDocAsMarkDown)
	router.PUT("/api/v1/docs/:name", docServer.UpdateDoc)
	router.DELETE("/api/v1/docs/:name", docServer.DeleteDoc)

	filesController := files.New()
	filesController.DirRoot = UserDocRoot
	FileRoutes := map[string]string{
		"ListFilesForDoc":  "/api/v1/files/list/:DocName",
		"UploadFile":       "/api/v1/files/uploadfile",
		"DeleteFile":       "/api/v1/files/delete/:DocName/*filepath",
		"ViewFile":         "/api/v1/files/view/:DocName/*filepath",
		"Command_OpenFile": "/api/v1/files/open/:DocName/*filepath",
		"Command_ShowFile": "/api/v1/files/show/:DocName/*filepath",
	}

	router.GET(FileRoutes["ListFilesForDoc"], filesController.ListForDoc)
	router.POST(FileRoutes["UploadFile"], filesController.UploadFile)
	router.DELETE(FileRoutes["DeleteFile"], filesController.DeleteFile)
	router.GET(FileRoutes["ViewFile"], filesController.ViewFile)
	router.POST(FileRoutes["Command_ShowFile"], filesController.ShowFile)

	//=== General file handling ===
	var wwwRoot string
	if *IsDevEnv {
		wwwRoot = exeRoot + path.Join("..", "Frontend", "public")
		wwwRoot = filepath.Clean(wwwRoot)
		// TODO:MED It would be good to check if the path exists here.
	} else {
		wwwRoot = path.Join(exeRoot, "www", "public")
		// TODO:MED It would be good to check if the path exists here.
	}
	wfs := webserver.New()
	wfs.DocRoot = wwwRoot
	router.NotFound = wfs.HandleNotFound

	chain := setupMiddleWareHandler(UseRequestLogger, router)

	if *UseStandaloneServer == true {
		runAsStandaloneServer(chain)
	} else {
		runServerWithGui(chain)
	}

}
Esempio n. 14
0
var (
	config = replicator.Config{}

	metricFlags = metrics.RegisterMetricFlags(pflag.CommandLine)

	glogFlags struct {
		logToStderr     string
		alsoLogToStderr string
		verbosity       string
		vmodule         string
		logBacktraceAt  string
	}

	fleetDriver   = pflag.String("fleet-driver", "http", "The driver to use for connections to fleet. (http, etcd)")
	fleetEndpoint = pflag.String("fleet-peers", "unix:///var/run/fleet.sock", "List of peers for the fleet client (comma separated).")
	dryRun        = pflag.Bool("dry-run", true, "Do not write to fleet.")
)

func init() {
	pflag.DurationVar(&config.TickerTime, "ticker-time", 60*time.Second, "Ticker time.")
	pflag.DurationVar(&config.DeleteTime, "delete-time", 60*time.Minute, "Time before deleting undesired units.")
	pflag.DurationVar(&config.UpdateCooldownTime, "update-cooldown-time", 15*time.Minute, "Time between updates of changed units.")

	pflag.StringVar(&config.MachineTag, "machine-tag", "", "The machine-tag to filter for.")
	pflag.StringVar(&config.UnitTemplate, "unit-template", "", "The template to render for new units. Prefix with @ to load from a file.")
	pflag.StringVar(&config.UnitPrefix, "unit-prefix", "", "The prefix for the units to identify.")

	pflag.StringVar(&glogFlags.logToStderr, "logtostderr", "true", "log to standard error instead of files")
	pflag.StringVar(&glogFlags.alsoLogToStderr, "alsologtostderr", "false", "log to standard error as well as files")
	pflag.StringVarP(&glogFlags.verbosity, "verbose", "v", "1", "log level for V logs")
	pflag.StringVar(&glogFlags.vmodule, "vmodule", "", "comma-separated list of pattern=N settings for file-filtered logging")
Esempio n. 15
0
	Left  *ListData
	Right *ListData
}

var (
	drawChan            chan bool
	newContainerChan    chan goDocker.Container
	removeContainerChan chan string
	doneChan            chan bool
	uiEventChan         chan view.UIEvent
	drawStatsChan       chan docklistener.StatsMsg
)

var logFileFlag = flag.String("log-file", "", "Path to log file")
var dockerEndpoint = flag.String("docker-endpoint", "", "Docker connection endpoint")
var helpFlag = flag.Bool("help", false, "help")
var versionFlag = flag.Bool("version", false, "print version")

func init() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: dockdash [options]\n\n")
		flag.PrintDefaults()
	}

	flag.Parse()

	if *helpFlag {
		flag.Usage()
		os.Exit(1)
	}
	if *versionFlag {