1
0
mirror of https://github.com/drone/drone-cli.git synced 2024-09-22 20:01:45 +02:00

Trim slash suffix from the server URL

This commit is contained in:
Thomas Boerger 2016-04-05 17:03:00 +02:00
parent 4ff82e8545
commit f71c0a6006

View File

@ -4,6 +4,7 @@ import (
"crypto/tls"
"fmt"
"os"
"strings"
"github.com/codegangsta/cli"
"github.com/drone/drone-go/drone"
@ -16,7 +17,7 @@ type handlerFunc func(*cli.Context, drone.Client) error
// sets up the environment.
func handle(c *cli.Context, fn handlerFunc) {
var token = c.GlobalString("token")
var server = c.GlobalString("server")
var server = strings.TrimSuffix(c.GlobalString("server"), "/")
// if no server url is provided we can default
// to the hosted Drone service.
@ -24,6 +25,7 @@ func handle(c *cli.Context, fn handlerFunc) {
fmt.Println("Error: you must provide the Drone server address.")
os.Exit(1)
}
if len(token) == 0 {
fmt.Println("Error: you must provide your Drone access token.")
os.Exit(1)