package gitlin

import (
  "github.com/spf13/cobra"

  "gitler.moe/suwako/gitlin/serve"
)

var port string = "9715"

var serveCmd = &cobra.Command{
  Use:   "serve",
  Short: "Start the web server.",
  Long:  `Start the web server.`,
  Run: func(cmd *cobra.Command, args []string) {
    serve.Serve(port)
  },
}

func init() {
  rootCmd.AddCommand(serveCmd)

  serveCmd.Flags().StringVarP(&port, "port", "p", "", "The port Gitlin will listen to. Defaults to 9715, and overrides the GITLIN_PORT environment variable.")

  // set port variable to the value of the port flag
  port = serveCmd.Flag("port").Value.String()
}
