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

Loading…
Cancel
Save