예제 #1
0
파일: main.go 프로젝트: pcarrier/acme
func main() {
	adaptflag.Adapt()
	cmd := kingpin.Parse()
	hooks.DefaultPath = *hooksFlag
	acmeapi.UserAgent = "acmetool"
	xlogconfig.Init()

	if *batchFlag {
		interaction.NonInteractive = true
	}

	if *stdioFlag {
		interaction.NoDialog = true
	}

	if *responseFileFlag == "" {
		p := filepath.Join(*stateFlag, "conf/responses")
		if _, err := os.Stat(p); err == nil {
			*responseFileFlag = p
		}
	}

	if *responseFileFlag != "" {
		err := loadResponseFile(*responseFileFlag)
		log.Errore(err, "cannot load response file, continuing anyway")
	}

	switch cmd {
	case "reconcile":
		cmdReconcile()
	case "cull":
		cmdCull()
	case "status":
		cmdStatus()
	case "account-thumbprint":
		cmdAccountThumbprint()
	case "want":
		cmdWant()
		if *wantReconcile {
			cmdReconcile()
		}
	case "unwant":
		cmdUnwant()
	case "quickstart":
		cmdQuickstart()
	case "redirector":
		cmdRunRedirector()
	case "test-notify":
		cmdRunTestNotify()
	case "import-key":
		cmdImportKey()
	case "import-jwk-account":
		cmdImportJWKAccount()
	case "import-le":
		cmdImportLE()
		cmdReconcile()
	case "revoke":
		cmdRevoke()
	}
}
예제 #2
0
func Example() {
	var (
		g           = cflag.NewGroup(nil, "Program Options")
		bindFlag    = cflag.String(g, "bind", ":80", "Address to bind server to (e.g. :80)")
		fooFlag     = cflag.String(g, "foo", "", "Some flag")
		barFlag     = cflag.Int(g, "bar", 42, "Some other flag")
		doStuffFlag = cflag.Bool(g, "doStuff", false, "Do stuff?")
	)

	adaptflag.Adapt()
	flag.Parse()

	fmt.Printf("Bind: %s\n", bindFlag.Value())
	fmt.Printf("Foo:  %s\n", fooFlag.Value())
	fmt.Printf("Bar:  %d\n", barFlag.Value())
	fmt.Printf("Do Stuff: %v\n", doStuffFlag.Value())
}
예제 #3
0
func Example() {
	type Config struct {
		Bind    string `usage:"Address to bind server to (e.g. :80)" default:":80"`
		Foo     string `usage:"Some flag" default:""`
		Bar     int    `usage:"Some other flag" default:"42"`
		DoStuff bool   `usage:"Do stuff?" default:"false"`
	}

	cfg := &Config{}
	configurable.Register(cstruct.MustNew(cfg, "test"))
	adaptflag.Adapt()
	flag.Parse()

	fmt.Printf("Bind: %s\n", cfg.Bind)
	fmt.Printf("Foo:  %s\n", cfg.Foo)
	fmt.Printf("Bar:  %d\n", cfg.Bar)
	fmt.Printf("Do Stuff: %v\n", cfg.DoStuff)
}
예제 #4
0
// Parse configuration values. tgt should be a pointer to a structure to be
// filled using cstruct. If nil, no structure is registered using cstruct.
func (cfg *Configurator) Parse(tgt interface{}) error {
	if tgt != nil && cfg.ProgramName != "" {
		if exepath.ProgramNameSetter == "default" {
			exepath.ProgramName = cfg.ProgramName
		}

		configurable.Register(cstruct.MustNew(tgt, cfg.ProgramName))
	}

	adaptflag.Adapt()
	adaptenv.Adapt()
	flag.Parse()
	if cfg.ProgramName != "" {
		err := adaptconf.Load(cfg.ProgramName)
		if err != nil {
			return err
		}
	}

	cfg.configFilePath = adaptconf.LastConfPath()
	return nil
}