api.go 477 B

123456789101112131415161718192021222324252627282930
  1. package cmd
  2. import (
  3. "fmt"
  4. "bitbucket.org/robert2206/automation/modules/docker"
  5. "github.com/urfave/cli"
  6. )
  7. // APICmd is a cli command to manage settings
  8. var APICmd = cli.Command{
  9. Name: "api",
  10. Action: runAPI,
  11. Flags: []cli.Flag{
  12. cli.StringFlag{
  13. Name: "host",
  14. Value: "127.0.0.1",
  15. },
  16. cli.StringFlag{
  17. Name: "port",
  18. Value: "8080",
  19. },
  20. },
  21. }
  22. func runAPI(ctx *cli.Context) error {
  23. ctrs, _ := docker.GetAllPublicPorts()
  24. fmt.Println(ctrs)
  25. return nil
  26. }