diff --git a/.travis.yml b/.travis.yml index f6b1ba4c62ec089e8287fd08d3f372bcb1cc5262..0330786ea85a547dbf8d11e6844e4b3a8080be9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: false matrix: include: - go: 1.5 - env: VERSION=0.1.0 + env: VERSION=0.2.0 before_deploy: - GOARCH=amd64 GOOS=linux go build boilr.go && tar czvf boilr-$VERSION-linux_amd64.tgz boilr diff --git a/README.md b/README.md index 443a18b25e153b96e63038d28a31f980e8b66f5c..b53bdda2207b70d3416cb5819495499e6df61c50 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [Travis]: http://travis-ci.org/tmrts/boilr [License Widget]: https://img.shields.io/badge/license-Apache%20License%202.0-E91E63.svg?style=flat-square [License]: https://github.com/tmrts/boilr/blob/master/LICENSE -[Release Widget]: https://img.shields.io/badge/release-v0.1.0-blue.svg?style=flat-square +[Release Widget]: https://img.shields.io/badge/release-v0.2.0-blue.svg?style=flat-square [Release]: https://github.com/tmrts/boilr/releases [Gitter Widget]: https://img.shields.io/badge/chat-on%20gitter-00BCD4.svg?style=flat-square [Gitter]: https://gitter.im/tmrts/boilr @@ -20,6 +20,8 @@ Are you doing the same steps over and over again every time you start a new prog `boilr` is a powerful language-agnostic command-line boilerplate template tool here to help you. + + For more details, see [Introduction](https://github.com/tmrts/boilr/wiki/Introduction) page. # Features @@ -28,17 +30,51 @@ For more details, see [Introduction](https://github.com/tmrts/boilr/wiki/Introdu - Full power of [golang templates](https://golang.org/pkg/text/template/) (Easy to learn & powerful) # Usage -To use templates shared by others and create your own please take a look at the -[Usage](https://github.com/tmrts/boilr/wiki/Usage) and [Creating Templates](https://github.com/tmrts/boilr/wiki/Creating-Templates) -pages in the wiki. +Use `boilr help` to get the list of available commands. -# Template Catalog -Take a look at [Templates](https://github.com/tmrts/boilr/wiki/Templates) page for a list of project templates, examples, and more information. +## Download a Template +In order to download a template from a github repository, use the following command: -# Contributing -If you'd like to contribute, share your opinions or learn more, please feel free to open an issue. +```bash +boilr template download <github-repo-path> <template-tag> +boilr template download tmrts/boilr-license license +``` -At this stage, user feedback is of **utmost importance**, every contribution is welcome however small it may be. +The downloaded template will be saved to local `boilr` registry. + +## Save a Local Template +In order to save a template from filesystem to the template registry use the following command: + +```bash +boilr template save <template-path> <template-tag> +boilr template save ~/boilr-license license +``` + +The saved template will be saved to local `boilr` registry. + +## Use a Template +In order to use a template from template registry use the following command: + +```bash +boilr template use <template-tag> <target-dir> +boilr template use license ~/Workspace/example-project/ +``` + +You will be prompted for values when using a template. + +```bash +[?] Please choose an option for "License" + 1 - "Apache Software License 2.0" + 2 - "MIT" + 3 - "GNU GPL v3.0" + Select from 1..3 [default: 1]: 2 +[?] Please choose a value for "Year" [default: "2015"]: +[?] Please choose a value for "Author" [default: "Tamer Tas"]: +[✔] Created /home/tmrts/project/LICENSE +[✔] Successfully executed the project template license in /home/tmrts/project +``` + +For more information please take a look at [Usage](https://github.com/tmrts/boilr/wiki/Usage) and [Creating Templates](https://github.com/tmrts/boilr/wiki/Creating-Templates) pages in the wiki. ## Reporting Issues You can report issues **directly from the command-line** by using the command, `boilr report`. @@ -49,6 +85,14 @@ is the issue body. After creating the issue, save & exit the editor and you will be prompted for github credentials needed to create the issue. +# Template Catalog +Take a look at [Templates](https://github.com/tmrts/boilr/wiki/Templates) page for a list of project templates, examples, and more information. + +# Contributing +If you'd like to contribute, share your opinions or learn more, please feel free to open an issue. + +At this stage, user feedback is of **utmost importance**, every contribution is welcome however small it may be. + # How Do I Get It? There are binaries available for Linux & OSX. You can download them directly, or run the installation script. Please see [Installation](https://github.com/tmrts/boilr/wiki/Installation) page for more information. diff --git a/install b/install index 6c4d47ef7a32515f22b96f16ea219028a0d2e8bc..d2f11087d13ef8ed8822e5ff64eb7d334fc653c1 100755 --- a/install +++ b/install @@ -2,8 +2,8 @@ set -u -[[ "$@" =~ --pre ]] && version=0.1.0 pre=1 || - version=0.1.0 pre=0 +[[ "$@" =~ --pre ]] && version=0.2.0 pre=1 || + version=0.2.0 pre=0 # If stdin is a tty, we are "interactive". interactive= @@ -37,7 +37,7 @@ configure() { auto_completion=$? fi - if [ $auto_completion -eq ]; then + if [ $auto_completion -eq 1 ]; then sudo $HOME/bin/boilr configure-bash-completion fi @@ -51,7 +51,7 @@ configure() { check_binary() { echo -n " - Checking boilr executable ... " local output - output=$("$HOME"/bin/boilr version 2>&1) + output=$("$HOME"/bin/boilr version --dont-prettify 2>&1) if [ $? -ne 0 ]; then echo "Error: $output" binary_error="Invalid binary" diff --git a/pkg/boilr/configuration.go b/pkg/boilr/configuration.go index 90607af69a9f3418c92bf6848e630347be68a367..37b2775ebcfd1ccba46696825be04483aca8ca8b 100644 --- a/pkg/boilr/configuration.go +++ b/pkg/boilr/configuration.go @@ -16,7 +16,7 @@ const ( AppName = "boilr" // Version of the application - Version = "0.1.0" + Version = "0.2.0" // ConfigDirPath is the configuration directory of the application ConfigDirPath = ".config/boilr" diff --git a/pkg/cmd/download.go b/pkg/cmd/download.go index c5cfa0375e21b574df6af9a52dbfdae963aa19ef..2994847c9a7244c46dc5a0a8f3fc474c960b0bef 100644 --- a/pkg/cmd/download.go +++ b/pkg/cmd/download.go @@ -144,6 +144,6 @@ var Download = &cli.Command{ exit.Error(fmt.Errorf("download: %s", err)) } - exit.OK("Successfully downloaded the template %v", templateName) + exit.OK("Successfully downloaded the template %#v", templateName) }, } diff --git a/pkg/cmd/init.go b/pkg/cmd/init.go index cd3b47f79431d01cbe46911f275577b1ba0804ba..b55360825a1f5edaa290872a5f0524cea03a8835 100644 --- a/pkg/cmd/init.go +++ b/pkg/cmd/init.go @@ -1,7 +1,6 @@ package cmd import ( - "errors" "fmt" cli "github.com/spf13/cobra" @@ -10,11 +9,6 @@ import ( "github.com/tmrts/boilr/pkg/util/osutil" ) -var ( - // ErrUninitializedboilrDir indicates that the local template registry is not initialized for boilr. - ErrUninitializedboilrDir = errors.New("boilr: .boilr directory is not initialized") -) - // Init contains the cli-command for initializing the local template // registry in case it's not initialized. var Init = &cli.Command{ @@ -24,7 +18,7 @@ var Init = &cli.Command{ // Check if .config/boilr exists if exists, err := osutil.DirExists(boilr.Configuration.TemplateDirPath); exists { if shouldRecreate := GetBoolFlag(c, "force"); !shouldRecreate { - exit.Error(ErrUninitializedboilrDir) + exit.GoodEnough("template registry is already initialized use -f to reinitialize") } } else if err != nil { exit.Error(fmt.Errorf("init: %s", err)) diff --git a/pkg/cmd/report.go b/pkg/cmd/report.go index 3f551ed117a107cc61fc4f6ac1ece7569667e00a..cbd50057ce15d7fbc4fc96750ebd966ba133cf83 100644 --- a/pkg/cmd/report.go +++ b/pkg/cmd/report.go @@ -71,8 +71,7 @@ func getIssue() (*github.IssueRequest, error) { } f.Close() - // TODO allow gedit, vi, emacs - cmd := exec.Command("vim", fname) + cmd := exec.Command("vi", fname) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index ee2cb4aa2f8b1c7d4014f9e1fb60e70ca7bbaf61..1c74cfdf8ba941b425d2fafeb0481b0fa48615f0 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -13,7 +13,6 @@ func Run() { // TODO use command factories instead of global command variables // TODO add describe command that shows template metadata information // TODO add create command that creates a minimal template template - // TODO rename template-tag to template-tag Template := &cli.Command{ Use: "template", diff --git a/pkg/cmd/save.go b/pkg/cmd/save.go index 4e56bcb2c4838cabcd87e852fa7154ce7cb0cd33..f2d76357669a5723524f10c22b06ef97edb75d32 100644 --- a/pkg/cmd/save.go +++ b/pkg/cmd/save.go @@ -16,7 +16,6 @@ import ( // Save contains the cli-command for saving templates to template registry. var Save = &cli.Command{ - // TODO rename template-tag to template-tag Use: "save <template-path> <template-tag>", Short: "Save a project template to local template registry", Run: func(c *cli.Command, args []string) { @@ -53,7 +52,6 @@ var Save = &cli.Command{ } if _, err := exec.Cmd("cp", "-r", tmplDir, targetDir); err != nil { - // TODO create exec package exit.Error(err) } diff --git a/pkg/cmd/use.go b/pkg/cmd/use.go index 39eb31dad35ddff87a67a0c10674d9eaa765f701..a577eaab17f287a09a4d22e6020a714f2be82a9e 100644 --- a/pkg/cmd/use.go +++ b/pkg/cmd/use.go @@ -3,6 +3,7 @@ package cmd import ( "fmt" "os" + "path/filepath" cli "github.com/spf13/cobra" @@ -36,7 +37,11 @@ var Use = &cli.Command{ MustValidateTemplateDir() - tmplName, targetDir := args[0], args[1] + tmplName := args[0] + targetDir, err := filepath.Abs(args[1]) + if err != nil { + exit.Fatal(fmt.Errorf("use: %s", err)) + } if ok, err := TemplateInRegistry(tmplName); err != nil { exit.Fatal(fmt.Errorf("use: %s", err)) diff --git a/pkg/prompt/prompt.go b/pkg/prompt/prompt.go index 58ab9cabfe2bc693c49e64497faa9fe9d60ae82f..fbb41a2b05eb5cc3676b9da3b315eb13beb8399e 100644 --- a/pkg/prompt/prompt.go +++ b/pkg/prompt/prompt.go @@ -10,7 +10,6 @@ import ( "github.com/tmrts/boilr/pkg/util/tlog" ) -// TODO align brackets used in the prompt message const ( // PromptFormatMessage is a format message for value prompts. PromptFormatMessage = "Please choose a value for %q" @@ -36,8 +35,6 @@ func newString(name string, defval interface{}) func() interface{} { return func() interface{} { if cache == nil { cache = func() interface{} { - // TODO use colored prompts - //fmt.Printf(PromptFormatMessage, name, defval) tlog.Prompt(fmt.Sprintf(PromptFormatMessage, name), defval) line, err := scanLine() diff --git a/pkg/template/template.go b/pkg/template/template.go index 18db20b81149b8fcbe5327df91d0b83a19d0223a..02fd202f490a0fe9f796ee1d9719f494d0b125d4 100644 --- a/pkg/template/template.go +++ b/pkg/template/template.go @@ -195,10 +195,10 @@ func (t *dirTemplate) Execute(dirPrefix string) error { if err := contentsTmpl.ExecuteTemplate(f, fileTemplateName, nil); err != nil { return err } - } - if !t.ShouldUseDefaults { - tlog.Success(fmt.Sprintf("Created %s", target)) + if !t.ShouldUseDefaults { + tlog.Success(fmt.Sprintf("Created %s", target)) + } } return nil diff --git a/pkg/util/exit/exit.go b/pkg/util/exit/exit.go index bedbb78302c9c7a909161389b8e7d1388fad1f39..8686f17e64d7d0303c8d682245feec7a2418ee08 100644 --- a/pkg/util/exit/exit.go +++ b/pkg/util/exit/exit.go @@ -34,7 +34,7 @@ func Error(err error) { // GoodEnough terminates execution successfully, but indicates that something is missing. func GoodEnough(fmtStr string, s ...interface{}) { - tlog.Debug(fmt.Sprintf(fmtStr, s...)) + tlog.Info(fmt.Sprintf(fmtStr, s...)) os.Exit(CodeOK) } diff --git a/pkg/util/tlog/log.go b/pkg/util/tlog/log.go index 16a13b4aa02cf9b614f6d7577bfd209322b34c10..ac69ef004f0c0014edca3da057699e71b223e856 100644 --- a/pkg/util/tlog/log.go +++ b/pkg/util/tlog/log.go @@ -26,7 +26,6 @@ const ( ErrorMark = "✘" // QuestionMark character indicates prompt message. - // TODO use for prompts QuestionMark = "?" ) diff --git a/usage.gif b/usage.gif new file mode 100644 index 0000000000000000000000000000000000000000..5d5b9b3144b75775c10828016957ba4f9c4cefc0 Binary files /dev/null and b/usage.gif differ