Skip to content

Commit

Permalink
allow update command to be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ddollar committed Sep 18, 2014
1 parent 57dca4c commit ec1d073
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 4 additions & 3 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ type Command struct {
Run func(cmd *Command, args []string)
Flag flag.FlagSet

Usage string // first word is the command name
Short string // `forego help` output
Long string // `forego help cmd` output
Disabled bool
Usage string // first word is the command name
Short string // `forego help` output
Long string // `forego help cmd` output
}

func (c *Command) printUsage() {
Expand Down
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

import (
"os"
)
import "os"

var commands = []*Command{
cmdStart,
Expand All @@ -12,13 +10,22 @@ var commands = []*Command{
cmdHelp,
}

var allowUpdate string = "true"

func main() {
args := os.Args[1:]
if len(args) < 1 {
usage()
}

if allowUpdate == "false" {
cmdUpdate.Disabled = true
}

for _, cmd := range commands {
if cmd.Disabled == true {
continue
}
if cmd.Name() == args[0] && cmd.Run != nil {
cmd.Flag.Usage = func() {
cmd.printUsage()
Expand Down

0 comments on commit ec1d073

Please sign in to comment.