Skip to content

Commit

Permalink
Merge pull request #138 from vim-volt/devel
Browse files Browse the repository at this point in the history
Release v0.2.2
  • Loading branch information
tyru authored Dec 24, 2017
2 parents 4203b29 + 354d5bc commit aea90c3
Show file tree
Hide file tree
Showing 17 changed files with 322 additions and 303 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ language: go
matrix:
include:
- os: linux
go: 1.9.1
go: 1.9
- os: linux
go: tip
- os: osx
osx_image: xcode8.3
go: 1.9.1
go: 1.9
- os: osx
osx_image: xcode8.3
go: tip
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ Or download binaries from [GitHub releases](https://github.com/vim-volt/volt/rel

## Build environment

* Go 1.9.1 or higher **with [the patch for os.RemoveAll()](https://go-review.googlesource.com/c/go/+/62970) ([#1](https://github.com/vim-volt/go-volt/issues/1))**
* Go 1.9 or higher
* If you are on WSL (Windows Subsystem Linux), note that you need **[the patch for os.RemoveAll()](https://go-review.googlesource.com/c/go/+/62970) ([#1](https://github.com/vim-volt/go-volt/issues/1))**
* But it's a hassle, you can just download linux-386/amd64 binaries from [GitHub releases](https://github.com/vim-volt/volt/releases) :)

## Self upgrade

Expand Down
42 changes: 17 additions & 25 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing/object"
)

type buildFlagsType struct {
var BuildModeInvalidType = os.ModeSymlink | os.ModeNamedPipe | os.ModeSocket | os.ModeDevice

func init() {
cmdMap["build"] = &buildCmd{}
}

type buildCmd struct {
helped bool
full bool
}

var buildFlags buildFlagsType

var BuildModeInvalidType = os.ModeSymlink | os.ModeNamedPipe | os.ModeSocket | os.ModeDevice
var ErrBuildModeType = "does not allow symlink, named pipe, socket, device"

func init() {
func (cmd *buildCmd) FlagSet() *flag.FlagSet {
fs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
fs.SetOutput(os.Stdout)
fs.Usage = func() {
Expand All @@ -62,22 +63,17 @@ Description
fmt.Println("Options")
fs.PrintDefaults()
fmt.Println()
buildFlags.helped = true
cmd.helped = true
}
fs.BoolVar(&buildFlags.full, "full", false, "full build")

cmdFlagSet["build"] = fs
fs.BoolVar(&cmd.full, "full", false, "full build")
return fs
}

type buildCmd struct{}

func Build(args []string) int {
cmd := buildCmd{}

func (cmd *buildCmd) Run(args []string) int {
// Parse args
fs := cmdFlagSet["build"]
fs := cmd.FlagSet()
fs.Parse(args)
if buildFlags.helped {
if cmd.helped {
return 0
}

Expand All @@ -89,7 +85,7 @@ func Build(args []string) int {
}
defer transaction.Remove()

err = cmd.doBuild(buildFlags.full)
err = cmd.doBuild(cmd.full)
if err != nil {
logger.Error("Failed to build:", err.Error())
return 12
Expand Down Expand Up @@ -799,12 +795,8 @@ func (cmd *buildCmd) updateNonBareGitRepos(r *git.Repository, src, dst string, r
continue
}
if file.Mode()&BuildModeInvalidType != 0 {
abspath := filepath.Join(src, file.Name())
done <- actionReposResult{
err: errors.New(ErrBuildModeType + ": " + abspath),
repos: repos,
}
return
// Currenly skip the invalid files...
continue
}
if !created[dst] {
os.MkdirAll(dst, 0755)
Expand Down
22 changes: 22 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

import (
"flag"

"github.com/vim-volt/volt/logger"
)

var cmdMap = make(map[string]Cmd)

type Cmd interface {
Run(args []string) int
FlagSet() *flag.FlagSet
}

func Run(subCmd string, args []string) int {
if self, exists := cmdMap[subCmd]; exists {
return self.Run(args)
}
logger.Error("Unknown command '" + subCmd + "'")
return 3
}
27 changes: 12 additions & 15 deletions cmd/disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import (
"github.com/vim-volt/volt/pathutil"
)

type disableFlagsType struct {
helped bool
func init() {
cmdMap["disable"] = &disableCmd{}
}

var disableFlags disableFlagsType
type disableCmd struct {
helped bool
}

func init() {
func (cmd *disableCmd) FlagSet() *flag.FlagSet {
fs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
fs.SetOutput(os.Stdout)
fs.Usage = func() {
Expand All @@ -33,17 +35,12 @@ Description
//fmt.Println("Options")
//fs.PrintDefaults()
fmt.Println()
disableFlags.helped = true
cmd.helped = true
}

cmdFlagSet["disable"] = fs
return fs
}

type disableCmd struct{}

func Disable(args []string) int {
cmd := disableCmd{}

func (cmd *disableCmd) Run(args []string) int {
reposPathList, err := cmd.parseArgs(args)
if err == ErrShowedHelp {
return 0
Expand All @@ -66,10 +63,10 @@ func Disable(args []string) int {
return 0
}

func (*disableCmd) parseArgs(args []string) ([]string, error) {
fs := cmdFlagSet["disable"]
func (cmd *disableCmd) parseArgs(args []string) ([]string, error) {
fs := cmd.FlagSet()
fs.Parse(args)
if disableFlags.helped {
if cmd.helped {
return nil, ErrShowedHelp
}

Expand Down
27 changes: 12 additions & 15 deletions cmd/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import (
"github.com/vim-volt/volt/pathutil"
)

type enableFlagsType struct {
helped bool
func init() {
cmdMap["enable"] = &enableCmd{}
}

var enableFlags enableFlagsType
type enableCmd struct {
helped bool
}

func init() {
func (cmd *enableCmd) FlagSet() *flag.FlagSet {
fs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
fs.SetOutput(os.Stdout)
fs.Usage = func() {
Expand All @@ -33,17 +35,12 @@ Description
//fmt.Println("Options")
//fs.PrintDefaults()
fmt.Println()
enableFlags.helped = true
cmd.helped = true
}

cmdFlagSet["enable"] = fs
return fs
}

type enableCmd struct{}

func Enable(args []string) int {
cmd := enableCmd{}

func (cmd *enableCmd) Run(args []string) int {
reposPathList, err := cmd.parseArgs(args)
if err == ErrShowedHelp {
return 0
Expand All @@ -66,10 +63,10 @@ func Enable(args []string) int {
return 0
}

func (*enableCmd) parseArgs(args []string) ([]string, error) {
fs := cmdFlagSet["enable"]
func (cmd *enableCmd) parseArgs(args []string) ([]string, error) {
fs := cmd.FlagSet()
fs.Parse(args)
if enableFlags.helped {
if cmd.helped {
return nil, ErrShowedHelp
}

Expand Down
Loading

0 comments on commit aea90c3

Please sign in to comment.