当前位置: 首页>>代码示例>>Golang>>正文


Golang devd.Devd类代码示例

本文整理汇总了Golang中github.com/cortesi/devd.Devd的典型用法代码示例。如果您正苦于以下问题:Golang Devd类的具体用法?Golang Devd怎么用?Golang Devd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Devd类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main


//.........这里部分代码省略.........
	).
		PlaceHolder("N").
		Short('u').
		Default("0").
		Uint()

	watch := kingpin.Flag("watch", "Watch path to trigger livereload").
		PlaceHolder("PATH").
		Short('w').
		Strings()

	excludes := kingpin.Flag("exclude", "Glob pattern for files to exclude from livereload").
		PlaceHolder("PATTERN").
		Short('x').
		Strings()

	debug := kingpin.Flag("debug", "Debugging for devd development").
		Default("false").
		Bool()

	routes := kingpin.Arg(
		"route",
		`Routes have the following forms:
			[SUBDOMAIN]/<PATH>=<DIR>
			[SUBDOMAIN]/<PATH>=<URL>
			<DIR>
			<URL>
		`,
	).Required().Strings()

	kingpin.Version(devd.Version)

	kingpin.Parse()

	realAddr := *address
	if *allInterfaces {
		realAddr = "0.0.0.0"
	}

	var creds *devd.Credentials
	if *credspec != "" {
		var err error
		creds, err = devd.CredentialsFromSpec(*credspec)
		if err != nil {
			kingpin.Fatalf("%s", err)
			return
		}
	}

	dd := devd.Devd{
		// Shaping
		Latency:  *latency,
		DownKbps: *downKbps,
		UpKbps:   *upKbps,

		// Livereload
		LivereloadRoutes: *livereloadRoutes,
		WatchPaths:       *watch,
		Excludes:         *excludes,

		Credentials: creds,
	}

	if err := dd.AddRoutes(*routes); err != nil {
		kingpin.Fatalf("%s", err)
	}

	if err := dd.AddIgnores(*ignoreLogs); err != nil {
		kingpin.Fatalf("%s", err)
	}

	logger := termlog.NewLog()
	if *quiet {
		logger.Quiet()
	}
	if *debug {
		logger.Enable("debug")
	}
	if *logTime {
		logger.Enable("timer")
	}
	if *logHeaders {
		logger.Enable("headers")
	}

	err := dd.Serve(
		realAddr,
		*port,
		*certFile,
		logger,
		func(url string) {
			if *openBrowser {
				webbrowser.Open(url)
			}
		},
	)
	if err != nil {
		kingpin.Fatalf("%s", err)
	}
}
开发者ID:rawbite,项目名称:devd,代码行数:101,代码来源:devd.go

示例2: main


//.........这里部分代码省略.........
		`,
	).Required().Strings()

	kingpin.Version(devd.Version)

	kingpin.Parse()

	if *moddMode {
		*forceColor = true
		*noTimestamps = true
		*livereloadNaked = true
	}

	realAddr := *address
	if *allInterfaces {
		realAddr = "0.0.0.0"
	}

	var creds *devd.Credentials
	if *credspec != "" {
		var err error
		creds, err = devd.CredentialsFromSpec(*credspec)
		if err != nil {
			kingpin.Fatalf("%s", err)
			return
		}
	}

	hdrs := make(http.Header)
	if *cors {
		hdrs.Set("Access-Control-Allow-Origin", "*")
	}

	dd := devd.Devd{
		// Shaping
		Latency:  *latency,
		DownKbps: *downKbps,
		UpKbps:   *upKbps,

		AddHeaders: &hdrs,

		// Livereload
		LivereloadRoutes: *livereloadRoutes,
		Livereload:       *livereloadNaked,
		WatchPaths:       *watch,
		Excludes:         *excludes,

		Credentials: creds,
	}

	if err := dd.AddRoutes(*routes); err != nil {
		kingpin.Fatalf("%s", err)
	}

	if err := dd.AddIgnores(*ignoreLogs); err != nil {
		kingpin.Fatalf("%s", err)
	}

	logger := termlog.NewLog()
	if *quiet {
		logger.Quiet()
	}
	if *debug {
		logger.Enable("debug")
	}
	if *logTime {
开发者ID:eticzon,项目名称:devd,代码行数:67,代码来源:devd.go

示例3: main


//.........这里部分代码省略.........
		Strings()

	livereloadRoutes := kingpin.Flag("livereload", "Enable livereload for static files").
		Short('l').
		Default("false").
		Bool()

	latency := kingpin.Flag("latency", "Add N milliseconds of round-trip latency").
		PlaceHolder("N").
		Short('n').
		Default("0").
		Int()

	openBrowser := kingpin.Flag("open", "Open browser window on startup").
		Short('o').
		Default("false").
		Bool()

	port := kingpin.Flag(
		"port",
		"Port to listen on - if not specified, devd will auto-pick a sensible port",
	).
		Short('p').
		Int()

	logTime := kingpin.Flag("logtime", "Log timing").
		Short('T').
		Default("false").
		Bool()

	upKbps := kingpin.Flag(
		"up",
		"Throttle upstream from the client to N kilobytes per second",
	).
		PlaceHolder("N").
		Short('u').
		Default("0").
		Uint()

	watch := kingpin.Flag("watch", "Watch path to trigger livereload").
		PlaceHolder("PATH").
		Short('w').
		Strings()

	debug := kingpin.Flag("debug", "Debugging for devd development").
		Default("false").
		Bool()

	excludes := kingpin.Flag("exclude", "Glob pattern for files to exclude from livereload.").
		PlaceHolder("PATTERN").
		Short('x').
		Strings()

	routes := kingpin.Arg(
		"route",
		`Routes have the following forms:
			[SUBDOMAIN]/<PATH>=<DIR>
			[SUBDOMAIN]/<PATH>=<URL>
			<DIR>
			<URL>
		`,
	).Required().Strings()

	kingpin.Version(devd.Version)

	kingpin.Parse()

	realAddr := *address
	if *allInterfaces {
		realAddr = "0.0.0.0"
	}

	dd := devd.Devd{
		Routes:      *routes,
		OpenBrowser: *openBrowser,
		CertFile:    *certFile,
		Address:     realAddr,
		Port:        *port,

		// Shaping
		Latency:  *latency,
		DownKbps: *downKbps,
		UpKbps:   *upKbps,

		// Livereload
		LivereloadRoutes: *livereloadRoutes,
		Watch:            *watch,
		Excludes:         *excludes,

		// Logging
		Debug:      *debug,
		LogHeaders: *logHeaders,
		LogTime:    *logTime,
		IgnoreLogs: *ignoreLogs,
	}
	err := dd.Serve()
	if err != nil {
		kingpin.Fatalf("%s", err)
	}
}
开发者ID:skyfree02,项目名称:devd,代码行数:101,代码来源:devd.go


注:本文中的github.com/cortesi/devd.Devd类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。