Skip to content

Commit

Permalink
Merge pull request #17 for v0.11.0 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm authored Jul 7, 2018
2 parents dc75b2f + 8641219 commit 4f863f5
Show file tree
Hide file tree
Showing 56 changed files with 1,940 additions and 3,365 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ _testmain.go
*.exe
*.test
*.prof
*.bak
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ branches:
- /^v[0-9.]+$/

go:
- 1.9
- "1.10"
- 1.9.x
- 1.x
- tip

go_import_path: aahframework.org/tools.v0/aah

before_install:
- bash <(curl -s https://aahframework.org/base-before-install)

install:
- go get -t -v ./...

Expand Down
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# tools - aah framework

Home of all aah framework CLI tools.

## aah CLI Tool
[![Build Status](https://travis-ci.org/go-aah/tools.svg?branch=master)](https://travis-ci.org/go-aah/tools) [![Go Report Card](https://goreportcard.com/badge/aahframework.org/tools.v0)](https://goreportcard.com/report/aahframework.org/tools.v0/aah)
[![Powered by Go](https://img.shields.io/badge/powered_by-go-blue.svg)](https://golang.org)
[![Version](https://img.shields.io/badge/version-0.10-blue.svg)](https://github.com/go-aah/tools/releases/latest)
[![License](https://img.shields.io/github/license/go-aah/tools.svg)](LICENSE) [![Twitter](https://img.shields.io/badge/twitter-@aahframework-55acee.svg)](https://twitter.com/aahframework)

***Release [v0.10](https://github.com/go-aah/tools/releases/latest) tagged on Mar 28, 2018***
<p align="center">
<img src="https://cdn.aahframework.org/assets/img/aah-logo-64x64.png" />
<h2 align="center">Home of all CLI tools by aah framework</h2>
</p>
<p align="center">
<p align="center"><a href="https://travis-ci.org/go-aah/tools"><img src="https://travis-ci.org/go-aah/tools.svg?branch=master" alt="Build Status"></a> <a href="https://goreportcard.com/report/aahframework.org/tools.v0"><img src="https://goreportcard.com/badge/aahframework.org/tools.v0" alt="Go Report Card"></a> <a href="https://godoc.org/aahframework.org/tools.v0"><img src="https://godoc.org/aahframework.org/tools.v0?status.svg" alt="Godoc"></a> <a href="https://twitter.com/aahframework"><img src="https://img.shields.io/badge/twitter-@aahframework-55acee.svg" alt="Twitter @aahframework"></a></p>
</p>

aah - A secure, flexible, rapid Go web framework.

Requires `go1.8` and above.
### News

* aah CLI <a href="https://github.com/go-aah/tools/releases/latest"><img src="https://img.shields.io/badge/version-0.11.0-blue.svg" alt="Release Version"></a> [released](https://github.com/go-aah/tools/releases/latest) and tagged on Jul 06, 2018.

Visit official website https://aahframework.org to learn more.
Visit official website https://aahframework.org to learn more about `aah` framework.
122 changes: 58 additions & 64 deletions aah/aah.go
Original file line number Diff line number Diff line change
@@ -1,50 +1,37 @@
// Copyright (c) Jeevanandam M. (https://github.com/jeevatkm)
// go-aah/tools/aah source code and usage is governed by a MIT style
// aahframework.org/aah source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

package main

import (
"errors"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"runtime"
"sort"
"strings"

"gopkg.in/urfave/cli.v1"

"aahframework.org/aah.v0"
"aahframework.org/ahttp.v0"
"aahframework.org/aruntime.v0"
"aahframework.org/config.v0"
"aahframework.org/essentials.v0"
"aahframework.org/i18n.v0"
"aahframework.org/log.v0"
"aahframework.org/router.v0"
"aahframework.org/security.v0"
"aahframework.org/test.v0"
"aahframework.org/valpar.v0"
"aahframework.org/view.v0"
)

const (
permRWXRXRX = 0755
permRWRWRW = 0666
versionSeries = "v0"
importPrefix = "aahframework.org"
permRWXRXRX = 0755
permRWRWRW = 0666
importPrefix = "aahframework.org"
)

var (
gopath string
gocmd string
gosrcDir string

libNames = []string{"tools", "aah", "ahttp", "aruntime", "config", "essentials", "forge", "i18n",
"log", "router", "security", "test", "valpar", "view"}
gitcmd string
aahVer string

// abstract it, so we can do unit test
fatal = log.Fatal
Expand All @@ -53,8 +40,13 @@ var (

// cli logger
cliLog *log.Logger

// CliPackaged is identify cli from go get or binary dist
CliPackaged string
)

var errStopHere = errors.New("stop here")

func checkPrerequisites() error {
// check go is installed or not
if !ess.LookExecutable("go") {
Expand All @@ -68,12 +60,38 @@ func checkPrerequisites() error {
return err
}

if gocmd, err = exec.LookPath("go"); err != nil {
// Go executable
gocmdName := goCmdName()
if gocmd, err = exec.LookPath(gocmdName); err != nil {
return err
}

gosrcDir = filepath.Join(gopath, "src")

// git
if gitcmd, err = exec.LookPath("git"); err != nil {
return err
}

// aah
if aahVer, err = aahVersion(); err == errVersionNotExists {
if collectYesOrNo(reader, "aah framework is not installed in GOPATH, would you like to install [Y]es or [N]o") {
args := []string{"get"}
if gocmdName == "go" {
args = append(args, "-u")
}
args = append(args, "aahframework.org/aah.v0")
if _, err := execCmd(gocmd, args, false); err != nil {
return err
}
aahVer, _ = aahVersion()
fmt.Printf("\naah framework successfully installed in GOPATH\n\n")
return nil
}
fmt.Printf("\nOkay, you could do it manually, run '%s get aahframework.org/aah.v0'\n", gocmdName)
return errStopHere
}

return nil
}

Expand All @@ -82,14 +100,16 @@ func main() {
// if panic happens, recover and abort nicely :)
defer func() {
if r := recover(); r != nil {
cfg, _ := config.ParseString(``)
strace := aruntime.NewStacktrace(r, cfg)
strace := aruntime.NewStacktrace(r, config.NewEmpty())
strace.Print(os.Stdout)
exit(2)
}
}()

if err := checkPrerequisites(); err != nil {
err := checkPrerequisites()
if err == errStopHere {
return
} else if err != nil {
logFatal(err)
}

Expand All @@ -112,6 +132,7 @@ func main() {
switchCmd,
updateCmd,
generateCmd,
migrateCmd,
}

sort.Sort(cli.FlagsByName(app.Flags))
Expand All @@ -123,66 +144,39 @@ func main() {
//___________________________________

func printHeader(c *cli.Context) error {
hdr := fmt.Sprintf("aah framework v%s - https://aahframework.org", aah.Version)
improveRpt := "# Report improvements/bugs at https://github.com/go-aah/aah/issues #"
hdrCont := fmt.Sprintf("aah framework v%s", aahVer)
improveRpt := "# Report improvements/bugs at https://aahframework.org/issues #"
cnt := len(improveRpt)
sp := (cnt - len(hdr)) / 2

if !isWindowsOS() {
fmt.Fprintf(c.App.Writer, "\033[1;32m")
}
sp := (cnt - len(hdrCont)) / 2

printChr(c.App.Writer, "‾", cnt)
fmt.Fprintf(c.App.Writer, "\n")
printChr(c.App.Writer, " ", sp)
fmt.Fprintf(c.App.Writer, hdr)
printChr(c.App.Writer, " ", sp)
fmt.Fprintf(c.App.Writer, "\n")
printChr(c.App.Writer, "_", cnt)
fmt.Fprintf(c.App.Writer, "\n")

if !isWindowsOS() {
fmt.Fprintf(c.App.Writer, "\033[0m")
}
fmt.Println(chr2str("-", cnt))
fmt.Println(chr2str(" ", sp) + hdrCont)
fmt.Println(chr2str("-", cnt))
fmt.Printf(improveRpt + "\n\n")

fmt.Fprintf(c.App.Writer, improveRpt+"\n\n")
return nil
}

func printChr(w io.Writer, chr string, cnt int) {
func chr2str(chr string, cnt int) string {
var str string
for idx := 0; idx < cnt; idx++ {
fmt.Fprintf(w, chr)
str += chr
}
return str
}

func init() {
cli.HelpFlag = cli.BoolFlag{
Name: "h, help",
Usage: "show help",
Usage: "Shows help",
}

cli.VersionFlag = cli.BoolFlag{
Name: "v, version",
Usage: "print aah framework version and go version",
Usage: "Prints cli, aah, go and aah libraries version",
}

cli.VersionPrinter = func(c *cli.Context) {
_ = printHeader(c)
fmt.Fprint(c.App.Writer, "Version Info:\n")
fmt.Fprintf(c.App.Writer, "\t%-17s v%s\n", "aah framework", aah.Version)
fmt.Fprintf(c.App.Writer, "\t%-17s v%s\n", "aah cli tool", Version)
fmt.Fprintf(c.App.Writer, "\t%-17s %s\n", "Modules: ", strings.Join(
[]string{
"ahttp v" + ahttp.Version, "aruntime v" + aruntime.Version, "config v" + config.Version,
"essentials v" + ess.Version, "i18n v" + i18n.Version, "log v" + log.Version}, ", "))
fmt.Fprintf(c.App.Writer, "\t%-17s %s\n", "", strings.Join(
[]string{"router v" + router.Version, "security v" + security.Version,
"test v" + test.Version, "valpar v" + valpar.Version, "view v" + view.Version}, ", "))
fmt.Println()
fmt.Fprintf(c.App.Writer, "\t%-17s %s\n", fmt.Sprintf("go[%s/%s]",
runtime.GOOS, runtime.GOARCH), runtime.Version()[2:])
fmt.Println()
}
cli.VersionPrinter = VersionPrinter

cli.AppHelpTemplate = `Usage:
{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
Expand Down
31 changes: 0 additions & 31 deletions aah/app-template/.gitignore

This file was deleted.

68 changes: 0 additions & 68 deletions aah/app-template/aah.project.atmpl

This file was deleted.

Loading

0 comments on commit 4f863f5

Please sign in to comment.