Browse Source

Added ide mode

pull/103/head
Unknown 11 years ago
parent
commit
b50baf1876
  1. 2
      cmd/build.go
  2. 2
      cmd/gen.go
  3. 2
      cmd/get.go
  4. 2
      cmd/install.go
  5. 2
      cmd/run.go
  6. 3
      gopm.go
  7. 37
      log/log.go
  8. 65
      log/logP.go
  9. 32
      log/log_windows.go

2
cmd/build.go

@ -36,6 +36,8 @@ gopm build <go build commands>`,
}
func runBuild(ctx *cli.Context) {
log.PureMode = ctx.GlobalBool("ide")
if !ctx.Bool("remote") {
// Get GOPATH.
installGopath = com.GetGOPATHs()[0]

2
cmd/gen.go

@ -41,6 +41,8 @@ Make sure you run this command in the root path of a go project.`,
// scan a directory and gen a gopm file
func runGen(ctx *cli.Context) {
log.PureMode = ctx.GlobalBool("ide")
if !com.IsExist(".gopmfile") {
os.Create(".gopmfile")
}

2
cmd/get.go

@ -68,6 +68,8 @@ func init() {
}
func runGet(ctx *cli.Context) {
log.PureMode = ctx.GlobalBool("ide")
// Check conflicts.
if ctx.Bool("gopath") && ctx.Bool("remote") {
log.Error("get", "Command options have conflicts")

2
cmd/install.go

@ -42,6 +42,8 @@ If no argument is supplied, then gopmfile must be present`,
}
func runInstall(ctx *cli.Context) {
log.PureMode = ctx.GlobalBool("ide")
var target string
switch len(ctx.Args()) {

2
cmd/run.go

@ -32,6 +32,8 @@ gopm run <go run commands>`,
}
func runRun(ctx *cli.Context) {
log.PureMode = ctx.GlobalBool("ide")
if !ctx.Bool("remote") {
// Get GOPATH.
installGopath = com.GetGOPATHs()[0]

3
gopm.go

@ -29,7 +29,7 @@ import (
// Test that go1.1 tag above is included in builds. main.go refers to this definition.
const go11tag = true
const APP_VER = "0.5.7.1205.4"
const APP_VER = "0.5.7.1205.5"
// //cmd.CmdSearch,
// cmdClean,
@ -61,5 +61,6 @@ func main() {
//cmd.CmdUpdate,
//cmd.CmdTest,
}
app.Flags = append(app.Flags, cli.BoolFlag{"ide, i", "IDE mode"})
app.Run(os.Args)
}

37
log/log.go

@ -25,6 +25,10 @@ import (
)
func Error(hl, msg string) {
if PureMode {
errorP(hl, msg)
}
if len(hl) > 0 {
hl = " " + brush.Red(hl).String()
}
@ -32,26 +36,50 @@ func Error(hl, msg string) {
}
func Fatal(hl, msg string) {
if PureMode {
fatal(hl, msg)
}
Error(hl, msg)
os.Exit(2)
}
func Warn(format string, args ...interface{}) {
if PureMode {
warn(format, args...)
return
}
fmt.Printf("gopm %s %s\n", brush.Purple("WARN"),
fmt.Sprintf(format, args...))
}
func Log(format string, args ...interface{}) {
if PureMode {
log(format, args...)
return
}
fmt.Printf("gopm %s %s\n", brush.White("INFO"),
fmt.Sprintf(format, args...))
}
func Trace(format string, args ...interface{}) {
if PureMode {
trace(format, args...)
return
}
fmt.Printf("gopm %s %s\n", brush.Blue("TRAC"),
fmt.Sprintf(format, args...))
}
func Success(title, hl, msg string) {
if PureMode {
success(title, hl, msg)
return
}
if len(hl) > 0 {
hl = " " + brush.Green(hl).String()
}
@ -59,6 +87,11 @@ func Success(title, hl, msg string) {
}
func Message(hl, msg string) {
if PureMode {
message(hl, msg)
return
}
if len(hl) > 0 {
hl = " " + brush.Yellow(hl).String()
}
@ -66,6 +99,10 @@ func Message(hl, msg string) {
}
func Help(format string, args ...interface{}) {
if PureMode {
help(format, atgs...)
}
fmt.Printf("gopm %s %s\n", brush.Cyan("HELP"),
fmt.Sprintf(format, args...))
os.Exit(2)

65
log/logP.go

@ -0,0 +1,65 @@
// Copyright 2013 gopm authors.
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package log
import (
"fmt"
"os"
)
var PureMode = false
func errorP(hl, msg string) {
if len(hl) > 0 {
hl = " " + hl
}
fmt.Printf("gopm ERR!%s %s\n", hl, msg)
}
func fatal(hl, msg string) {
Error(hl, msg)
os.Exit(2)
}
func warn(format string, args ...interface{}) {
fmt.Printf("gopm WARN %s\n", fmt.Sprintf(format, args...))
}
func log(format string, args ...interface{}) {
fmt.Printf("gopm INFO %s\n", fmt.Sprintf(format, args...))
}
func trace(format string, args ...interface{}) {
fmt.Printf("gopm TRAC %s\n", fmt.Sprintf(format, args...))
}
func success(title, hl, msg string) {
if len(hl) > 0 {
hl = " " + hl
}
fmt.Printf("gopm %s%s %s\n", title, hl, msg)
}
func message(hl, msg string) {
if len(hl) > 0 {
hl = " " + hl
}
fmt.Printf("gopm MSG!%s %s\n", hl, msg)
}
func help(format string, args ...interface{}) {
fmt.Printf("gopm HELP %s\n", fmt.Sprintf(format, args...))
os.Exit(2)
}

32
log/log_windows.go

@ -15,50 +15,34 @@
// Package log provides npm-like style log output.
package log
import (
"fmt"
"os"
)
func Error(hl, msg string) {
if len(hl) > 0 {
hl = " " + hl
}
fmt.Printf("gopm ERR!%s %s\n", hl, msg)
errorP(hl, msg)
}
func Fatal(hl, msg string) {
Error(hl, msg)
os.Exit(2)
fatal(hl, msg)
}
func Warn(format string, args ...interface{}) {
fmt.Printf("gopm WARN %s\n", fmt.Sprintf(format, args...))
warn(format, args...)
}
func Log(format string, args ...interface{}) {
fmt.Printf("gopm INFO %s\n", fmt.Sprintf(format, args...))
log(format, args...)
}
func Trace(format string, args ...interface{}) {
fmt.Printf("gopm TRAC %s\n", fmt.Sprintf(format, args...))
trace(format, args...)
}
func Success(title, hl, msg string) {
if len(hl) > 0 {
hl = " " + hl
}
fmt.Printf("gopm %s%s %s\n", title, hl, msg)
success(title, hl, msg)
}
func Message(hl, msg string) {
if len(hl) > 0 {
hl = " " + hl
}
fmt.Printf("gopm MSG!%s %s\n", hl, msg)
message(hl, msg)
}
func Help(format string, args ...interface{}) {
fmt.Printf("gopm HELP %s\n", fmt.Sprintf(format, args...))
os.Exit(2)
help(format, args...)
}

Loading…
Cancel
Save