Beispiel #1
0
func init() {
	flags := getopt.New()
	register(&formatter{
		name:  "types",
		f:     doTypes,
		help:  "display found types",
		flags: flags,
	})
	flags.BoolVarLong(&typesDebug, "types_debug", 0, "display debug information")
	flags.BoolVarLong(&typesVerbose, "types_verbose", 0, "include base information")
}
Beispiel #2
0
func init() {
	flags := getopt.New()
	register(&formatter{
		name:  "proto",
		f:     doProto,
		help:  "display tree in a proto like format",
		flags: flags,
	})
	flags.BoolVarLong(&proto2, "proto2", 0, "produce proto2 protobufs")
	flags.StringVarLong(&protoDir, "proto_dir", 0, "write a .proto file for each module in DIR", "DIR")
	flags.BoolVarLong(&protoNoComments, "proto_no_comments", 0, "do not include comments in output")
	flags.BoolVarLong(&protoFlat, "proto_flat", 0, "do not produce nested protobufs")
	flags.StringVarLong(&protoPreserve, "proto_save", 0, "preserve existing .proto files as filename.SUFFIX", "SUFFIX")
	flags.BoolVarLong(&protoWithSource, "proto_with_source", 0, "add source location comments")
}
Beispiel #3
0
func NewSSHOptions() *SSHOptions {
	sshOptions := &SSHOptions{}

	opts := getopt.New()

	sshOptions.indexOption = opts.UintVarLong(
		&sshOptions.Index,
		"index",
		'i',
		"application instance index",
		"app-instance-index",
	)

	sshOptions.skipHostValidationOption = opts.BoolVarLong(
		&sshOptions.SkipHostValidation,
		"skip-host-validation",
		'k',
		"skip host key validation",
	).SetFlag()

	sshOptions.skipRemoteExecutionOption = opts.BoolVar(
		&sshOptions.SkipRemoteExecution,
		'N',
		"do not execute a remote command",
	).SetFlag()

	var force, disable bool
	sshOptions.forceTerminalAllocationOption = opts.BoolVar(&force, 't', "force pseudo-tty allocation").SetFlag()
	sshOptions.disableTerminalAllocationOption = opts.BoolVar(&disable, 'T', "disable pseudo-tty allocation").SetFlag()

	sshOptions.localForwardMultiVal = &multiopt.MultiValue{}
	sshOptions.localForwardingOption = opts.Var(
		sshOptions.localForwardMultiVal,
		'L',
		"local port forward specification",
		"[bind_address:]port:host:hostport",
	)

	sshOptions.getoptSet = opts

	return sshOptions
}
Beispiel #4
0
	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/options/multiopt"
	"github.com/pborman/getopt"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Multiopt", func() {
	var (
		opts *getopt.Set
		mv   *multiopt.MultiValue
		args []string
	)

	BeforeEach(func() {
		opts = getopt.New()
		mv = &multiopt.MultiValue{}

		opts.Var(mv, 'L', "help string")

		args = []string{"ssh", "-L8080:example.com:80", "-L9443:example.com:443"}
	})

	JustBeforeEach(func() {
		err := opts.Getopt(args, nil)
		Expect(err).NotTo(HaveOccurred())
	})

	Describe("Values", func() {
		It("aggregates values for an option", func() {
			Expect(mv.Values()).To(ConsistOf("8080:example.com:80", "9443:example.com:443"))
Beispiel #5
0
  mv [-fT] SOURCE... DEST
  mkdir [-p] FILE...
  touch [-amc] FILE...
  chmod [-R] OCTAL-MODE FILE...
  chown [-R] OWNER[:GROUP] FILE...
  cat SOURCE...
  head [-n LINES | -c BYTES] SOURCE...
  tail [-n LINES | -c BYTES] SOURCE...
  du [-sh] FILE...
  checksum FILE...
  get SOURCE [DEST]
  getmerge SOURCE DEST
  put SOURCE DEST
`, os.Args[0])

	lsOpts = getopt.New()
	lsl    = lsOpts.Bool('l')
	lsa    = lsOpts.Bool('a')
	lsh    = lsOpts.Bool('h')

	rmOpts = getopt.New()
	rmr    = rmOpts.Bool('r')
	rmf    = rmOpts.Bool('f')

	mvOpts = getopt.New()
	mvf    = mvOpts.Bool('f')
	mvT    = mvOpts.Bool('T')

	mkdirOpts = getopt.New()
	mkdirp    = mkdirOpts.Bool('p')
func ParseFlags(args []string) (*Options, error) {
	cmd := args[0]

	if cmd != "scp" {
		return nil, errors.New("Usage: call scp")
	}

	opts := getopt.New()

	targetMode := opts.Bool('t', "", "Sets target mode for scp")
	opts.Lookup('t').SetOptional()

	sourceMode := opts.Bool('f', "", "Sets source mode for scp")
	opts.Lookup('f').SetOptional()

	targetIsDirectory := opts.Bool('d', "", "Indicates that the target is a directory")
	opts.Lookup('d').SetOptional()

	verbose := opts.Bool('v', "", "Indicates that the command should be run in verbose mode")
	opts.Lookup('v').SetOptional()

	preserveTimesAndMode := opts.Bool('p', "", "Indicates that scp should preserve timestamps and mode of files/directories transferred")
	opts.Lookup('p').SetOptional()

	recursive := opts.Bool('r', "", "Indicates a recursive transfer, must be set if source is a directory")
	opts.Lookup('r').SetOptional()

	// showprogress option is not used but can be provided
	quiet := opts.Bool('q', "", "Indicates that the user wishes to run in quiet mode")
	opts.Lookup('q').SetOptional()

	err := opts.Getopt(args, nil)
	if err != nil {
		return nil, err
	}

	if *targetMode == *sourceMode {
		return nil, errors.New("Must specify either target mode(-t) or source mode(-f) at a time")
	}

	var sources []string
	var target string

	if *sourceMode {
		if len(opts.Args()) < 1 {
			return nil, errors.New("Must specify at least one source in source mode")
		}

		sources = opts.Args()
	}

	if *targetMode {
		if len(opts.Args()) != 1 {
			return nil, errors.New("Must specify one target in target mode")
		}

		target = opts.Args()[0]
	}

	return &Options{
		TargetMode:           *targetMode,
		SourceMode:           *sourceMode,
		TargetIsDirectory:    *targetIsDirectory,
		Verbose:              *verbose,
		PreserveTimesAndMode: *preserveTimesAndMode,
		Recursive:            *recursive,
		Quiet:                *quiet,
		Sources:              sources,
		Target:               target,
	}, nil
}
Beispiel #7
0
func main() {

	/*
	 *	lolclient connect port
	 *  lolclient path
	 *  game connect port
	 *  tgp parameter
	 *
	 */

	/*
	 *	本工具参数
	 */
	var lolclient_port uint16
	var lolroot_path string
	var lolobfile string
	var lolgame_port uint16
	var help bool = false
	//	var version bool = false
	fmt.Println()
	fmt.Println("版    本: lol_launcher_mac " + LAUNCHER_VERSION + " build at " + BUILD_DATE + " By CFC4N ([email protected])")
	fmt.Println("声    明: 本软件仅供技术交流,游戏娱乐,请勿用于非法用途。\n")

	s := getopt.New()

	/*
	 *	接收本工具参数
	 */
	//	s.StringVarLong(&lolroot_path, "path", 'X', "The root path of League of Legends games", "/Applications/League of Legends.app/")
	//	s.Uint16VarLong(&lolclient_port, "client_port", 'Y',"The port LolClient connected.")
	s.StringVarLong(&lolobfile, "obfile", 'f', "ob录像文件所在路径,建议放在replays目录下。")
	s.Parse(os.Args)
	if help {
		s.PrintUsage(os.Stderr)
		return
	}

	if len(lolobfile) <= 0 {
		s.PrintUsage(os.Stderr)
		return
	}
	lolroot_path = getCurrentDirectory()

	lolCommands := command.NewLolCommand()
	//设置游戏安装目录,以及日志目录
	lolCommands.LolSetConfigPath("/Applications/League of Legends.app/", lolroot_path)

	//获取游戏中,大厅程序以及游戏进程程序所在目录等配置
	lolCommands.LolGetConfig()

	/*
	 *
	 * 参数判断
	 */
	if lolclient_port <= 0 || lolclient_port >= 65535 {
		lolclient_port = DEFAULT_CLIENT_PORT
	}

	if lolgame_port <= 0 || lolgame_port >= 65535 {
		lolgame_port = DEFAULT_GAME_PORT
	}

	/*
	 *
	 */

	//观看录像模式
	log.Println("录像观看模式已启动...")
	filePath := lolroot_path + "/" + lolobfile
	log.Println("加载录像文件:", filePath)
	//加载分析OB文件
	err := replay.Loadfile(filePath)
	if err != nil {
		panic(err)
	}
	listenHost := "127.0.0.1:" + strconv.Itoa(int(DEFAULT_REPLAY_PORT))
	//		fmt.Println(replay.GameInfo)
	//		os.Exit(0)
	params := "spectator " + listenHost + " " + replay.GameInfo.Encryption_key + " " + strconv.Itoa(int(replay.GameInfo.Game_id)) + " " + replay.GameMetaData.GameKey.PlatformId

	// log.SetOutput(f)
	log.Println("录像回放服务已监听:", listenHost)

	r := mux.NewRouter()
	mw.Decorate(
		r,
		LoggingMW,
	)

	r.HandleFunc("/observer-mode/rest/featured", replay.FeaturedHandler)
	r.HandleFunc("/observer-mode/rest/consumer/version", replay.VersionHandler)
	r.HandleFunc("/observer-mode/rest/consumer/getGameMetaData/{platformId}/{gameId}/{yolo}/token", replay.GetGameMetaDataHandler)
	r.HandleFunc("/observer-mode/rest/consumer/getLastChunkInfo/{platformId}/{gameId}/{param}/token", replay.GetLastChunkInfoHandler)
	r.HandleFunc("/observer-mode/rest/consumer/getLastChunkInfo/{platformId}/{gameId}/null", replay.EndOfGameStatsHandler)
	r.HandleFunc("/observer-mode/rest/consumer/getGameDataChunk/{platformId}/{gameId}/{chunkId}/token", replay.GetGameDataChunkHandler)
	r.HandleFunc("/observer-mode/rest/consumer/getKeyFrame/{platformId}/{gameId}/{keyFrameId}/token", replay.GetKeyFrameHandler)

	http.Handle("/", r)
	//启动游戏
	//		log.Println("录像播放参数:",params)

	go lolCommands.LolGameCommand(strconv.Itoa(int(lolgame_port)), params)
	if err := http.ListenAndServe(listenHost, nil); err != nil {
		panic(err)
	}
	//监听系统关闭消息
	log.Println("软件退出。")
	os.Exit(0)

}
Beispiel #8
0
)

var (
	usage = fmt.Sprintf(`
	Presto Metrico  - Collect and send Presto Metrics to datadog

	OPTIONS:
 -c
 The coordinator node we are going to pull metrics from
 -d
 The uri for the statsd client. Defaults to 127.0.0.1:8125
 -t
 The time in secs between sending metrics
`)

	commandOptions      = getopt.New()
	coordinatorOpts     = commandOptions.StringLong("coordinator", 'c', "", "Address of the Presto coordinator")
	dogstatsdServerOpts = commandOptions.StringLong("dogstatsd", 'd', "127.0.0.1:8125", "Address for the statsd server")
	metricsIntervalOpts = commandOptions.IntLong("timer", 't', 15, "Time in seconds to trigger timer to send metrics")
)

func printHelp() {
	log.Println(usage)
	os.Exit(0)
}

func main() {
	if len(os.Args) < 2 {
		printHelp()
	}