From 1e80925ca7bd6c7256cd85cfe8fd304826ea30ca Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 13 Jul 2015 11:39:28 -0700 Subject: [PATCH] Remove dependency on minio/cli for make.go fixes #738 --- Makefile | 8 ++++---- cmd/mkdonut/make.go | 35 +++++++++++++---------------------- make.go | 35 +++++++++++++---------------------- 3 files changed, 30 insertions(+), 48 deletions(-) diff --git a/Makefile b/Makefile index 4a4411528..dbcf36107 100644 --- a/Makefile +++ b/Makefile @@ -33,13 +33,13 @@ cyclo: gomake-all: getdeps verifiers @echo "Installing minio:" - @go run make.go install - @go run cmd/mkdonut/make.go install + @go run make.go -install + @go run cmd/mkdonut/make.go -install release: getdeps verifiers @echo "Installing minio:" - @go run make.go release - @go run make.go install + @go run make.go -release + @go run make.go -install godepupdate: @for i in $(grep ImportPath Godeps/Godeps.json | grep -v minio/minio | cut -f2 -d: | sed -e 's/,//' -e 's/^[ \t]*//' -e 's/[ \t]*$//' -e 's/\"//g'); do godep update $i; done diff --git a/cmd/mkdonut/make.go b/cmd/mkdonut/make.go index 366ebc1fd..bd918f9b6 100644 --- a/cmd/mkdonut/make.go +++ b/cmd/mkdonut/make.go @@ -20,13 +20,12 @@ package main import ( "bytes" + "flag" "fmt" "os" "os/exec" "text/template" "time" - - "github.com/minio/cli" ) type Version struct { @@ -86,10 +85,7 @@ func (c command) String() string { return message } -func runMkdonutInstall(ctx *cli.Context) { - if ctx.Args().First() == "help" { - cli.ShowCommandHelpAndExit(ctx, "install", 1) // last argument is exit code - } +func runMkdonutInstall() { mkdonutInstall := command{exec.Command("godep", "go", "install", "-a", "github.com/minio/minio/cmd/mkdonut"), &bytes.Buffer{}, &bytes.Buffer{}} mkdonutInstallErr := mkdonutInstall.runCommand() if mkdonutInstallErr != nil { @@ -99,10 +95,7 @@ func runMkdonutInstall(ctx *cli.Context) { fmt.Print(mkdonutInstall) } -func runMkdonutRelease(ctx *cli.Context) { - if ctx.Args().First() == "help" { - cli.ShowCommandHelpAndExit(ctx, "release", 1) // last argument is exit code - } +func runMkdonutRelease() { t := time.Now().UTC() date := t.Format(time.RFC3339Nano) version := Version{Date: date} @@ -114,17 +107,15 @@ func runMkdonutRelease(ctx *cli.Context) { } func main() { - app := cli.NewApp() - app.Commands = []cli.Command{ - { - Name: "release", - Action: runMkdonutRelease, - }, - { - Name: "install", - Action: runMkdonutInstall, - }, + releaseFlag := flag.Bool("release", false, "make a release") + installFlag := flag.Bool("install", false, "install mkdonut") + + flag.Parse() + + if *releaseFlag { + runMkdonutRelease() + } + if *installFlag { + runMkdonutInstall() } - app.Author = "Minio.io" - app.RunAndExitOnError() } diff --git a/make.go b/make.go index e831ab8a2..60ef0a5f0 100644 --- a/make.go +++ b/make.go @@ -20,13 +20,12 @@ package main import ( "bytes" + "flag" "fmt" "os" "os/exec" "text/template" "time" - - "github.com/minio/cli" ) type Version struct { @@ -87,10 +86,7 @@ func (c command) String() string { return message } -func runMinioInstall(ctx *cli.Context) { - if ctx.Args().First() == "help" { - cli.ShowCommandHelpAndExit(ctx, "install", 1) // last argument is exit code - } +func runMinioInstall() { minioGenerate := command{exec.Command("godep", "go", "generate", "./..."), &bytes.Buffer{}, &bytes.Buffer{}} minioBuild := command{exec.Command("godep", "go", "build", "-a", "./..."), &bytes.Buffer{}, &bytes.Buffer{}} minioTest := command{exec.Command("godep", "go", "test", "-race", "./..."), &bytes.Buffer{}, &bytes.Buffer{}} @@ -121,10 +117,7 @@ func runMinioInstall(ctx *cli.Context) { fmt.Print(minioInstall) } -func runMinioRelease(ctx *cli.Context) { - if ctx.Args().First() == "help" { - cli.ShowCommandHelpAndExit(ctx, "release", 1) // last argument is exit code - } +func runMinioRelease() { t := time.Now().UTC() date := t.Format(time.RFC3339Nano) version := Version{Date: date} @@ -136,17 +129,15 @@ func runMinioRelease(ctx *cli.Context) { } func main() { - app := cli.NewApp() - app.Commands = []cli.Command{ - { - Name: "release", - Action: runMinioRelease, - }, - { - Name: "install", - Action: runMinioInstall, - }, + releaseFlag := flag.Bool("release", false, "make a release") + installFlag := flag.Bool("install", false, "install minio") + + flag.Parse() + + if *releaseFlag { + runMinioRelease() + } + if *installFlag { + runMinioInstall() } - app.Author = "Minio.io" - app.RunAndExitOnError() }