Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More user friendly hologram CLI #110

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions buildscripts/compile_hologram.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ source ${HOLOGRAM_DIR}/buildscripts/returncodes.sh
# go get -u github.com/kardianos/govendor

echo "Compiling for linux..."
GOOS=linux go install github.com/AdRoll/hologram/... || exit ${ERRCOMPILE}
GOOS=linux go install -ldflags="-X main.currentVersion=${GIT_TAG}" github.com/AdRoll/hologram/... || exit ${ERRCOMPILE}

echo "Compiling for osx"
GOOS=darwin go install github.com/AdRoll/hologram/... || exit ${ERRCOMPILE}
GOOS=darwin go install -ldflags="-X main.currentVersion=${GIT_TAG}" github.com/AdRoll/hologram/... || exit ${ERRCOMPILE}

echo "Running tests..."
go test -v github.com/AdRoll/hologram/... || exit ${ERRTEST}
57 changes: 30 additions & 27 deletions cmd/hologram/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package main

import (
"flag"
"fmt"
"io/ioutil"
"os"
Expand All @@ -25,38 +24,42 @@ import (
"github.com/AdRoll/hologram/protocol"
"github.com/AdRoll/hologram/transport/local"
"github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
)

func main() {
flag.Parse()

args := flag.Args()
var currentVersion = "UNKNOWN" // overwritten during build with GIT_TAG

var err error

if len(args) < 1 {
fmt.Println("Usage: hologram <cmd>")
os.Exit(1)
func main() {
var rootCmd = &cobra.Command{
Use: "hologram [command]",
Short: "Easy, painless AWS credentials on developer laptops",
Long: `Easy, painless AWS credentials on developer laptops
The hologram CLI is a tool from the https://github.com/AdRoll/hologram application`,
Version: currentVersion,
}

switch args[0] {
case "use":
if len(args) < 2 {
fmt.Println("Usage: hologram use <role>")
os.Exit(1)
}
err = use(args[1])
break
case "me":
err = me()
break
default:
fmt.Println("Usage: hologram use <role>")
os.Exit(1)
var useCmd = &cobra.Command{
Use: "use <role>",
Short: "Use a specific role",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return use(args[0])
},
}
var meCmd = &cobra.Command{
Use: "me",
Short: "Use your default role",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return me()
},
}

if err != nil {
log.Errorf(err.Error())
rootCmd.AddCommand(
useCmd,
meCmd,
)

if rootCmd.Execute() != nil {
os.Exit(1)
}
}
Expand Down
13 changes: 13 additions & 0 deletions vendor/github.com/inconshreveable/mousetrap/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions vendor/github.com/inconshreveable/mousetrap/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/inconshreveable/mousetrap/trap_others.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 98 additions & 0 deletions vendor/github.com/inconshreveable/mousetrap/trap_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading