Example #1
0
func setup_flags() *gnuflag.FlagSet {
	flags := gnuflag.NewFlagSet(os.Args[0], gnuflag.ExitOnError)

	flags.BoolVar(&help, "help", false, "Print this help message.")
	flags.BoolVar(&help, "h", false, "Print this help message.")

	flags.StringVar(&config.cmd, "command", "", "Command to execute.")
	flags.StringVar(&config.cmd, "C", "", "Command to execute.")

	flags.Uint64Var(&config.tick, "tick", 2000, "How often to check (milliseconds).")
	flags.Uint64Var(&config.tick, "t", 2000, "How often to check (milliseconds).")

	flags.Parse(true, os.Args[1:])

	return flags
}
Example #2
0
func setup() *gnuflag.FlagSet {
	flags := gnuflag.NewFlagSet(os.Args[0], gnuflag.ExitOnError)

	flags.BoolVar(&help, "help", false, "Print this help message")
	flags.BoolVar(&help, "h", false, "Print this help message")

	flags.BoolVar(&version, "version", false, "Print this help message")
	flags.BoolVar(&version, "V", false, "Print this help message")

	flags.StringVar(&config.workDir, "workdir", ".book", "Set the working directory.")
	flags.StringVar(&config.workDir, "w", ".book", "Set the working directory.")

	flags.StringVar(&config.epubFile, "output", "", "Set the output .epub file name.")
	flags.StringVar(&config.epubFile, "o", "", "Set the output .epub file name.")

	flags.Parse(true, os.Args[1:])

	return flags
}
Example #3
0
// TODO Dry-run cmd arg
func main() {
	flags := gnuflag.NewFlagSet("gop", gnuflag.ExitOnError)

	flags.BoolVar(&help, "help", false, "Print this help message")
	flags.BoolVar(&help, "h", false, "Print this help message")

	flags.BoolVar(&verbose, "verbose", false, "Be verbose")
	flags.BoolVar(&verbose, "v", false, "Be verbose")

	flags.BoolVar(&version, "version", false, "Print version and exit")
	flags.BoolVar(&version, "V", false, "Print version and exit")

	flags.StringVar(&vcs, "vcs", "", "Set the version control system")

	flags.Parse(true, os.Args[1:])

	if help {
		printUsage(flags)
		os.Exit(0)
	}

	if version {
		printVersion()
		os.Exit(0)
	}

	setpath(flags.Args())
	if verbose {
		fmt.Printf("Initialising Go workspace at %s\n", baseDir)
	}
	initWorkspace()

	if vcsFn, ok := vcsFns[vcs]; ok {
		vcsFn()
	}
}