Example #1
0
func main() {
	app := cli.NewApp()
	app.Name = appName
	app.Usage = "Eleant static website generator"
	app.Authors = authors
	app.Version = version
	app.Commands = []cli.Command{
		cli.Command{
			Name:        "build",
			ShortName:   "b",
			Usage:       "build site",
			Description: "build site",
			Action:      build,
			Flags:       buildFlags(),
		},
		cli.Command{
			Name:        "serve",
			ShortName:   "s",
			Usage:       "builds and serves the project",
			Description: "serves site",
			Action:      serve,
			Flags:       buildFlags(),
		},
	}
	app.Run(os.Args)
}
Example #2
0
func getApp() *cli.App {
	app := cli.NewApp()
	app.Name = "gobot"
	app.Usage = "a web crawler written in Go"
	app.Version = "0.0.1"

	app.Commands = []cli.Command{
		{
			Name:    "crawl",
			Aliases: []string{"c"},
			Usage:   "crawl a domain",
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:  "domain, d",
					Usage: "`DOMAIN` to crawl",
				},
			},
			Action: func(c *cli.Context) error {
				dmn := c.String("domain")
				url, err := url.Parse(fmt.Sprintf("http://%s/", dmn))
				if err != nil {
					log.Fatal(err)
				}
				sm, err := crawler.Crawl(*url)
				if err != nil {
					log.Fatal(err)
				}
				fmt.Printf("%s\n", sm)
				return nil
			},
		},
	}
	return app
}
Example #3
0
func main() {
	logger := log.NewLogfmtLogger(os.Stderr)
	logger = log.NewContext(logger).With("ts", log.DefaultTimestampUTC)

	err := godotenv.Load()
	if err != nil {
		logger.Log("level", "fatal", "err", err)
	}

	config := &Config{
		Addr: os.Getenv("ADDR"),
		DSN:  os.Getenv("DSN"),
	}

	db, err := gorm.Open("postgres", config.DSN)
	if err != nil {
		panic(err)
	}

	app := cli.NewApp()

	app.Commands = []cli.Command{{
		Name:   "serve",
		Action: serve(logger, config, db),
	}}

	if err := app.Run(os.Args); err != nil {
		logger.Log("level", "fatal", "err", err)
	}

}
Example #4
0
func main() {
	if setting.RunMode == "prod" {
		log.SetFormatter(&log.JSONFormatter{})
		log.SetOutput(os.Stderr)
	}

	app := cli.NewApp()

	app.Name = setting.AppName
	app.Usage = setting.Usage
	app.Version = setting.Version
	app.Author = setting.Author
	app.Email = setting.Email

	app.Commands = []cli.Command{
		cmd.CmdWeb,
		cmd.CmdDatabase,
		cmd.CmdOSS,
		cmd.CmdMonitor,
		cmd.CmdClient,
	}

	app.Flags = append(app.Flags, []cli.Flag{}...)
	app.Run(os.Args)
}
Example #5
0
func main() {
	app := cc.NewApp()

	app.Name = "recause"
	app.Usage = "Simple log management server that receives logs in GELF format"
	app.Version = "0.0.4"
	app.Authors = []cc.Author{
		{
			Name:  "Nikita Vershinin",
			Email: "*****@*****.**",
		},
	}
	app.Flags = []cc.Flag{
		cc.StringFlag{
			Name:  "config, c",
			Value: "/etc/recause/config.cfg",
			Usage: "path to the configuration file",
		},
	}

	app.Action = actionRun

	err := app.Run(os.Args)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Unhandled error occurred while running application: %v\n", err)
	}
}
Example #6
0
func main() {
	app := cli.NewApp()
	app.Name = "ionblogbuilder"
	app.Flags = []cli.Flag{
		cli.IntFlag{
			Name:  "webport, P",
			Value: 80,
			Usage: "The webserver port",
		},
		cli.IntFlag{
			Name:   "port, p",
			Value:  5566,
			Usage:  "The port github will use to send webhooks",
			EnvVar: "PORT,IONBLOG_PORT",
		},
		cli.StringFlag{
			Name:   "secret, s",
			Usage:  "Github secret key",
			EnvVar: "IONBLOG_SECRET",
		},
		cli.StringFlag{
			Name:   "output, o",
			Usage:  "Output directory",
			EnvVar: "IONBLOG_OUTPUT",
		},
	}

	app.Action = IonblogServerAction

	app.Run(os.Args)
}
Example #7
0
File: bch.go Project: cemcatik/bch
func main() {
	app := cli.NewApp()
	app.Name = "bch"
	app.Usage = "Generate and verify bcrypt password hashes"
	app.Commands = []cli.Command{
		{
			Name:  "hash",
			Usage: "Generate bcrypt password hash",
			Flags: []cli.Flag{
				cli.IntFlag{
					Name:  "factor, f",
					Value: 12,
					Usage: "work factor",
				},
			},
			Action: hash,
		},
		{
			Name:      "verify",
			Usage:     "Verify given hash against entered password",
			ArgsUsage: "[hash]",
			Action:    verify,
		},
	}

	app.Run(os.Args)
}
Example #8
0
func TestCommandYamlFileTestGlobalEnvVarWinsNested(t *testing.T) {
	app := cli.NewApp()
	set := flag.NewFlagSet("test", 0)
	ioutil.WriteFile("current.yaml", []byte(`top:
  test: 15`), 0666)
	defer os.Remove("current.yaml")

	os.Setenv("THE_TEST", "10")
	defer os.Setenv("THE_TEST", "")
	test := []string{"test-cmd", "--load", "current.yaml"}
	set.Parse(test)

	c := cli.NewContext(app, set, nil)

	command := &cli.Command{
		Name:        "test-cmd",
		Aliases:     []string{"tc"},
		Usage:       "this is for testing",
		Description: "testing",
		Action: func(c *cli.Context) error {
			val := c.Int("top.test")
			expect(t, val, 10)
			return nil
		},
		Flags: []cli.Flag{
			NewIntFlag(cli.IntFlag{Name: "top.test", EnvVar: "THE_TEST"}),
			cli.StringFlag{Name: "load"}},
	}
	command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))

	err := command.Run(c)

	expect(t, err, nil)
}
Example #9
0
func main() {
	app := cli.NewApp()
	app.Name = "space"
	app.Usage = "A user management microservice; OAuth 2 provider"
	app.EnableBashCompletion = true
	app.Commands = []cli.Command{
		{
			Name:    "serve",
			Aliases: []string{"s"},
			Usage:   "Serve the application server",
			Action: func(c *cli.Context) error {
				tasks.Server()
				return nil
			},
		},
		{
			Name:    "client",
			Aliases: []string{"c"},
			Usage:   "Manage client application",
			Subcommands: []cli.Command{
				{
					Name:  "create",
					Usage: "Create a new client application",
					Action: func(c *cli.Context) error {
						tasks.CreateClient()
						return nil
					},
				},
			},
		},
	}

	app.Run(os.Args)
}
Example #10
0
func NewApp(baseName string, cmdRunner command_runner.Runner, metadatas ...command_metadata.CommandMetadata) (app *cli.App) {

	cli.AppHelpTemplate = appHelpTemplate()
	cli.CommandHelpTemplate = commandHelpTemplate()
	app = cli.NewApp()
	app.Name = appConfig.Name
	app.HelpName = appConfig.HelpName
	app.Usage = appConfig.Usage
	app.Version = appConfig.Version

	app.Flags = []cli.Flag{
		cli.BoolFlag{
			Name:  "skipSslChecks",
			Usage: "Skip verification of server's certificate chain and hostname (for use with self-signed certs)",
		},
	}

	app.Commands = []cli.Command{}

	for _, metadata := range metadatas {
		primaryCommand := getCommand(baseName, metadata, cmdRunner)
		app.Commands = append(app.Commands, primaryCommand)
	}
	return
}
Example #11
0
func NewApp(baseName string, cmdRunner command_runner.Runner, metadatas ...command_metadata.CommandMetadata) (app *cli.App) {

	cli.AppHelpTemplate = appHelpTemplate()
	cli.CommandHelpTemplate = commandHelpTemplate()
	app = cli.NewApp()
	app.Name = appConfig.Name
	app.HelpName = appConfig.HelpName
	app.Usage = appConfig.Usage
	app.Version = appConfig.Version

	app.Flags = []cli.Flag{
		cli.BoolFlag{
			Name:  "skipSslChecks",
			Usage: "Skip verification of server's certificate chain and hostname (for use with self-signed certs)",
		},
		cli.StringFlag{
			Name:  "json, j",
			Usage: "Render value as json with json path selector as described at https://github.com/NodePrime/jsonpath. (Experimental, not supported on all commands at present) ",
		},
	}

	app.Commands = []cli.Command{}

	for _, metadata := range metadatas {
		primaryCommand := getCommand(baseName, metadata, cmdRunner)
		app.Commands = append(app.Commands, primaryCommand)
	}
	return
}
Example #12
0
func main() {
	app := cli.NewApp()
	app.Name = "cli"
	app.Usage = "cli [command] [args...]"
	app.Commands = []cli.Command{
		{
			Name:  "server",
			Usage: "Run the MerkleEyes server",
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:  "address",
					Value: "unix://data.sock",
					Usage: "MerkleEyes server listen address",
				},
				cli.StringFlag{
					Name:  "tmsp",
					Value: "socket",
					Usage: "socket | grpc",
				},
			},
			Action: func(c *cli.Context) {
				cmdServer(app, c)
			},
		},
	}
	app.Run(os.Args)

}
Example #13
0
func main() {
	app := cli.NewApp()
	app.Name = path.Base(os.Args[0])
	app.Author = "Manfred Touron"
	app.Email = "https://github.com/moul/advanced-ssh-config"
	app.Version = version.VERSION + " (" + version.GITCOMMIT + ")"
	app.Usage = "advanced ssh config"
	app.EnableBashCompletion = true
	app.BashComplete = BashComplete

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:   "config, c",
			EnvVar: "ASSH_CONFIG",
			Value:  "~/.ssh/assh.yml",
			Usage:  "Location of config file",
		},
		cli.BoolFlag{
			Name:   "debug, D",
			EnvVar: "ASSH_DEBUG",
			Usage:  "Enable debug mode",
		},
		cli.BoolFlag{
			Name:  "verbose, V",
			Usage: "Enable verbose mode",
		},
	}

	app.Before = hookBefore

	app.Commands = commands.Commands

	app.Run(os.Args)
}
Example #14
0
func main() {
	app := cli.NewApp()
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "docker, d",
			Value: "unix:///var/run/docker.sock",
			Usage: "Docker address",
		},
		cli.StringFlag{
			Name:  "label-filter, f",
			Value: "router=fusis",
			Usage: "Label to lookup when listing docker containers",
		},
		cli.DurationFlag{
			Name:  "interval, i",
			Value: time.Minute,
			Usage: "Interval between calls docker listing containers.\n" +
				"Docker events will also be used, pooling interval is a failsafe mechanism for missed events",
		},
		cli.StringFlag{
			Name:  "fusis-addr, a",
			Value: "",
			Usage: "Address of the fusis router",
		},
	}
	app.Version = "0.1.0"
	app.Name = "fusis-agent"
	app.Action = runAgent
	app.Author = "fusis team"
	app.Email = "https://github.com/luizbafilho/fusis"
	app.Run(os.Args)
}
Example #15
0
func main() {
	app := cli.NewApp()
	app.Name = "oci-runtime-tool"
	app.Version = "0.0.1"
	app.Usage = "OCI (Open Container Initiative) runtime tools"
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "log-level",
			Value: "error",
			Usage: "Log level (panic, fatal, error, warn, info, or debug)",
		},
		cli.BoolFlag{
			Name:  "host-specific",
			Usage: "generate host-specific configs or do host-specific validations",
		},
	}

	app.Commands = []cli.Command{
		generateCommand,
		bundleValidateCommand,
	}

	if err := app.Run(os.Args); err != nil {
		logrus.Fatal(err)
	}
}
Example #16
0
func main() {
	app := cli.NewApp()

	app.Name = "bulletin"
	app.Version = "0.0.1"
	app.Usage = "Service for exposing dynamic information from other services for collection and parsing"
	app.Action = setup

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "host, H",
			Value: "::",
			Usage: "Bind to `HOST`",
		},
		cli.IntFlag{
			Name:  "port, P",
			Value: 2626,
			Usage: "Bind to `PORT`",
		},
		cli.StringFlag{
			Name:  "dir, d",
			Value: "/var/lib/bulletin",
			Usage: "Load data from `DIR`",
		},
		cli.BoolFlag{
			Name:  "debug",
			Usage: "Print debug information",
		},
	}

	app.Run(os.Args)
}
Example #17
0
func main() {
	app := cli.NewApp()
	app.Name = "coverage generator"
	app.Usage = "generate and publish coverage reports"
	app.Version = version
	app.Before = setup
	app.Flags = []cli.Flag{
		cli.BoolFlag{
			Name:   "ci",
			Usage:  "continuous integration mode",
			EnvVar: "CI",
		},
		cli.BoolTFlag{
			Name:   "debug",
			Usage:  "debug mode",
			EnvVar: "DEBUG",
		},
	}
	app.Commands = []cli.Command{
		LcovCmd,
		GocovCmd,
		PublishCmd,
	}

	app.Run(os.Args)
}
Example #18
0
func TestCommandTomlFileTestDefaultValueFileWinsNested(t *testing.T) {
	app := cli.NewApp()
	set := flag.NewFlagSet("test", 0)
	ioutil.WriteFile("current.toml", []byte("[top]\ntest = 15"), 0666)
	defer os.Remove("current.toml")

	test := []string{"test-cmd", "--load", "current.toml"}
	set.Parse(test)

	c := cli.NewContext(app, set, nil)

	command := &cli.Command{
		Name:        "test-cmd",
		Aliases:     []string{"tc"},
		Usage:       "this is for testing",
		Description: "testing",
		Action: func(c *cli.Context) error {
			val := c.Int("top.test")
			expect(t, val, 15)
			return nil
		},
		Flags: []cli.Flag{
			NewIntFlag(cli.IntFlag{Name: "top.test", Value: 7}),
			cli.StringFlag{Name: "load"}},
	}
	command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load"))

	err := command.Run(c)

	expect(t, err, nil)
}
Example #19
0
func init() {
	// Initialise a CLI app
	cliApp = cli.NewApp()
	cliApp.Name = "Example API CLI"
	cliApp.Usage = "example-api"
	cliApp.Version = "0.0.0"
}
Example #20
0
// Run the CLI
func Run() {
	cli.VersionPrinter = printVersion

	app := cli.NewApp()
	app.Name = path.Base(os.Args[0])
	app.Usage = "bitrise-machine"
	app.Version = "0.9.10"

	app.Author = ""
	app.Email = ""

	app.Before = before

	app.Flags = appFlags
	app.Commands = commands

	if cpuProfileFilePath := os.Getenv(CPUProfileFilePathEnvKey); cpuProfileFilePath != "" {
		log.Infof("Enabling CPU Profiler, writing results into file: %s", cpuProfileFilePath)
		f, err := os.Create(cpuProfileFilePath)
		if err != nil {
			log.Fatalf("CPU Profile: failed to create file: %s", err)
		}
		if err := pprof.StartCPUProfile(f); err != nil {
			log.Fatalf("CPU Profile: failed to start CPU profiler: %s", err)
		}
		defer pprof.StopCPUProfile()
	}

	if err := app.Run(os.Args); err != nil {
		log.Fatal("Finished with error:", err)
	}
}
Example #21
0
func main() {
	var language string

	app := cli.NewApp()
	app.Name = "boom"
	app.Usage = "make an explosive entrance"

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:        "lang",
			Value:       "english",
			Usage:       "language for the greeting",
			Destination: &language,
		},
	}

	app.Action = func(c *cli.Context) error {
		fmt.Printf("c.NArg() = %v\n", c.NArg())
		fmt.Printf("c.String(\"lang\") = %v\n", c.String("lang"))
		fmt.Printf("language = %v", language)
		return nil
	}

	app.Run(os.Args)
}
Example #22
0
func main() {
	app := cli.NewApp()
	app.Name = "MeshBird"
	app.Usage = "distributed private networking"
	app.Version = Version
	app.Commands = []cli.Command{
		{
			Name:      "new",
			Aliases:   []string{"n"},
			Usage:     "create new network",
			Action:    actionNew,
			ArgsUsage: "<key>",
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:  "CIDR",
					Value: "10.7.0.0/16",
					Usage: "Define custom CIDR",
				},
			},
		},
		{
			Name:    "join",
			Aliases: []string{"j"},
			Usage:   "join network",
			Action:  actionJoin,
		},
		{
			Name:      "ip",
			Aliases:   []string{"i"},
			Usage:     "init state",
			Action:    actionGetIP,
			ArgsUsage: "<key>",
		},
	}
	app.Before = func(context *cli.Context) error {
		log.SetLevel(log.MustParseLevel(LogLevel))
		return nil
	}

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:        "key",
			Usage:       "set network key",
			Destination: &NetworkKey,
			EnvVar:      "MESHBIRD_KEY",
		},
		cli.StringFlag{
			Name:        "loglevel",
			Value:       "warning",
			Usage:       "set log level",
			Destination: &LogLevel,
			EnvVar:      "MESHBIRD_LOG_LEVEL",
		},
	}

	if err := app.Run(os.Args); err != nil {
		log.Fatal("error on run app, %v", err)
	}
}
Example #23
0
func main() {
	app := cli.NewApp()
	app.Name = "pepper"
	app.Version = "0.1.0"
	app.Usage = "pepper <target> <function> [ARGUMENTS ...]"
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:   "hostname, H",
			Usage:  "Salt API hostname. Should include http[s]//.",
			EnvVar: "SALT_HOST",
		},
		cli.StringFlag{
			Name:   "username, u",
			Usage:  "Salt API username.",
			EnvVar: "SALT_USER",
		},
		cli.StringFlag{
			Name:   "password, p",
			Usage:  "Salt API password.",
			EnvVar: "SALT_PASSWORD",
		},

		cli.StringFlag{
			Name:   "auth, a",
			Value:  "ldap",
			Usage:  "Salt authentication method.",
			EnvVar: "SALT_AUTH",
		},
	}
	app.Action = func(c *cli.Context) error {
		if len(c.Args()) < 2 {
			fmt.Println("pepper <target> <function> [ARGUMENTS ...]")
			return nil
		}

		hostname := c.String("hostname")
		username := c.String("username")
		password := c.String("password")
		auth := c.String("auth")

		salt := NewSalt(hostname)

		err := salt.Login(username, password, auth)
		if err != nil {
			log.Fatal(err)
		}

		target := c.Args().Get(0)
		function := c.Args().Get(1)
		arguments := c.Args().Get(2)

		response, _ := salt.Run(target, function, arguments)
		fmt.Println(response)
		return nil
	}

	app.Run(os.Args)

}
Example #24
0
func SecurityCliContext() *cli.Context {
	app := cli.NewApp()
	set := flag.NewFlagSet("test", flag.ContinueOnError)
	set.String("security", "aws-internal", "apply security")
	set.String("aws-role", "test-role", "apply security")
	context := cli.NewContext(app, set, nil)
	return context
}
Example #25
0
func main() {
	app := cli.NewApp()
	app.Name = "chip8"
	app.Usage = "Run chip8 programs using a Go based emulator"
	app.Commands = []cli.Command{
		cmdRun,
	}
	app.Run(os.Args)
}
Example #26
0
func main() {
	app := cli.NewApp()
	app.Name = "go-go"
	app.Version = version()
	app.ArgsUsage = "<project-name>"
	app.Action = run
	app.Flags = []cli.Flag{}
	app.Run(os.Args)
}
func main() {
	app := cli.NewApp()
	app.Name = "google-apps-utils"
	app.Version = Version
	app.Author = "Hiroki Yagita"
	app.Usage = "Google Apps Utils with Directory/Reports API"
	app.Commands = Commands
	app.Run(os.Args)
}
Example #28
0
func init() {
	// Initialise a CLI app
	cliApp = cli.NewApp()
	cliApp.Name = "go-oauth2-server"
	cliApp.Usage = "Go OAuth 2.0 Server"
	cliApp.Author = "Richard Knop"
	cliApp.Email = "*****@*****.**"
	cliApp.Version = "0.0.0"
}
Example #29
0
func main() {
	app := cli.NewApp()
	app.Name = "Etcd healthcheck proxy"
	app.Usage = "Ensure Etcd's raft index has caught up with the cluster before reporting healthy"
	app.Commands = []cli.Command{
		ProxyCommand(),
	}
	app.Run(os.Args)
}
Example #30
0
func main() {
	app := cli.NewApp()
	app.Name = "Hupu-iMan-getOnvif"
	app.Version = "1.2"
	app.Usage = "Using the onvif protocol for the camera information"
	app.Author = "CodyGuo"
	app.Email = "*****@*****.**"

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "host",
			Value: "127.0.0.1",
			Usage: "host address",
		},
		cli.StringFlag{
			Name:  "username, u",
			Value: "admin",
			Usage: "username for the host",
		},
		cli.StringFlag{
			Name:  "password, p",
			Value: "admin",
			Usage: "password for the host",
		},
	}

	onvif := NewOnvif()

	app.Action = func(c *cli.Context) error {
		argNum := len(c.Args())
		flagsNum := c.NumFlags()
		if argNum < 3 && flagsNum < 3 {
			fmt.Println("NotAuthorized.")
			// cli.ShowAppHelp(c)
		}
		if argNum == 3 {
			onvif.IP = c.Args()[0]
			onvif.Username = c.Args()[1]
			onvif.Password = c.Args()[2]
		}

		if flagsNum == 5 {
			onvif.IP = c.String("host")
			onvif.Username = c.String("username")
			onvif.Password = c.String("password")
		}

		result, _ := onvif.OnvifDevice()
		// if err != nil {
		// 	return err
		// }
		fmt.Println(result)
		return nil
	}

	app.Run(os.Args)
}