Skip to content

Commit

Permalink
Merge pull request #121 from cristiklein/popper-init-folder
Browse files Browse the repository at this point in the history
Popper init folder
  • Loading branch information
ivotron committed Jun 16, 2017
2 parents b1db612 + 4d04091 commit 43157d1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
14 changes: 14 additions & 0 deletions build-me.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
set -e

if [ -z "`which docker`" ]; then
echo "Could not find docker." >&2
echo "Please use the following script to install it: https://get.docker.com/." >&2
exit 1
fi

docker run --rm -v `pwd`/popper:/app -w /app treeder/go vendor
docker run --rm -v `pwd`/popper:/app -w /app treeder/go build

echo "Success. Popper is available at 'popper/app'."
echo "Note that the executable requires libc-musl: https://www.musl-libc.org/."
17 changes: 12 additions & 5 deletions popper/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ package main
import (
"fmt"
"log"
"os"

"github.com/codeskyblue/go-sh"
"github.com/spf13/cobra"
)

var initCmd = &cobra.Command{
Use: "init",
Use: "init [<folder>]",
Short: "Initializes a popper repository.",
Long: ``,
Long: "If <folder> is given then the repository is created in that folder, otherwise in the current directory.",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 0 {
log.Fatalln("This command doesn't take arguments.")
if len(args) > 1 {
log.Fatalln("This command takes at most one argument.")
}

if len(args) == 1 {
os.MkdirAll(args[0], 0777);
os.Chdir(args[0]);
}

// check for git repo and popperized repo
Expand All @@ -37,7 +43,8 @@ var initCmd = &cobra.Command{
log.Fatalln(err)
}

fmt.Println("Initialized Popper repository.")
cwd, _ := os.Getwd()
fmt.Println("Initialized Popper repository in '" + cwd + "'.")
},
}

Expand Down

0 comments on commit 43157d1

Please sign in to comment.