Browse Source

Improve command prompt

pull/103/head
Unknown 11 years ago
parent
commit
0bd637d616
  1. 19
      cmd/cmd.go
  2. 2
      cmd/get.go
  3. 1072
      cmd/serve.go
  4. 81
      gopm.go

19
cmd/cmd.go

@ -20,8 +20,6 @@ import (
"strings"
)
const APP_VER = "0.5.1.1105"
var (
AppPath string
reposDir string = "~/.gopm/repos"
@ -69,20 +67,3 @@ func (c *Command) Usage() {
func (c *Command) Runnable() bool {
return c.Run != nil
}
var CmdVersion = &Command{
UsageLine: "version",
Short: "show version",
Long: `
show version
`,
}
func runVersion(cmd *Command, args []string) {
fmt.Println(APP_VER)
}
func init() {
CmdVersion.Run = runVersion
CmdVersion.Flags = map[string]bool{}
}

2
cmd/get.go

@ -192,7 +192,7 @@ func downloadPackages(nodes []*doc.Node) {
com.ColorLog("[SUCC] Downloaded package( %s => %s:%s )\n",
n.ImportPath, n.Type, doc.CheckNodeValue(n.Value))
downloadCount++
saveNode(nod)
//saveNode(nod)
}
} else {
com.ColorLog("[WARN] Skipped downloaded package( %s => %s:%s )\n",

1072
cmd/serve.go

File diff suppressed because it is too large Load Diff

81
gopm.go

@ -17,8 +17,6 @@ package main
import (
"fmt"
"github.com/Unknwon/com"
"github.com/gpmgo/gopm/cmd"
"io"
"os"
"runtime"
@ -27,6 +25,10 @@ import (
"text/template"
"unicode"
"unicode/utf8"
//"github.com/Unknwon/com"
"github.com/gpmgo/gopm/cmd"
)
// +build go1.1
@ -34,37 +36,35 @@ import (
// Test that go1.1 tag above is included in builds. main.go refers to this definition.
const go11tag = true
var (
config map[string]interface{}
)
const APP_VER = "0.5.1.1108"
// Commands lists the available commands and help topics.
// The order here is the order in which they are printed by 'gopm help'.
var commands = []*cmd.Command{
cmd.CmdGet,
cmd.CmdSearch,
cmd.CmdServe,
//cmd.CmdSearch,
//cmd.CmdServe,
cmd.CmdGen,
cmd.CmdBuild,
cmd.CmdRun,
cmd.CmdVersion,
/*cmd.CmdInstall,
cmdClean,
cmdDoc,
cmdEnv,
cmdFix,
cmdFmt,
cmdList,
cmdTest,
cmdTool,
cmdVet,
helpGopath,
helpPackages,
helpRemote,
helpTestflag,
helpTestfunc,*/
cmd.CmdBuild,
cmd.CmdInstall,
/*
cmdClean,
cmdDoc,
cmdEnv,
cmdFix,
cmdFmt,
cmdList,
cmdTest,
cmdTool,
cmdVet,
helpGopath,
helpPackages,
helpRemote,
helpTestflag,
helpTestfunc,*/
}
func init() {
@ -88,16 +88,16 @@ func main() {
// Check commands and run.
for _, comm := range commands {
if comm.Name() == args[0] && comm.Run != nil {
if comm.Name() != "serve" {
err := cmd.AutoRun()
if err == nil {
comm.Run(comm, args[1:])
} else {
com.ColorLog("[ERRO] %v\n", err)
}
} else {
comm.Run(comm, args[1:])
}
// if comm.Name() != "serve" {
// err := cmd.AutoRun()
// if err == nil {
// comm.Run(comm, args[1:])
// } else {
// com.ColorLog("[ERRO] %v\n", err)
// }
// } else {
comm.Run(comm, args[1:])
// }
exit()
return
}
@ -119,11 +119,8 @@ func setExitStatus(n int) {
exitMu.Unlock()
}
var usageTemplate = `gopm is a package manage tool for Go programming language.
Usage:
gopm command [arguments]
var usageTemplate = `
Usage: gopm <command> [args]
The commands are:
{{range .}}{{if .Runnable}}
@ -137,7 +134,7 @@ Additional help topics:
Use "gopm help [topic]" for more information about that topic.
`
` + `gopm@` + APP_VER + "\n"
var helpTemplate = `{{if .Runnable}}usage: gopm {{.UsageLine}}

Loading…
Cancel
Save