more shortcut commands
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
d86e39f9ed
commit
758e7d157b
5
chomp.go
5
chomp.go
|
@ -7,6 +7,7 @@ package shell
|
|||
*/
|
||||
|
||||
import "log"
|
||||
import "fmt"
|
||||
import "reflect"
|
||||
import "strings"
|
||||
import "bytes"
|
||||
|
@ -67,7 +68,11 @@ func Chomp(a interface{}) string {
|
|||
bytesSplice = tmp.Bytes()
|
||||
return Chomp(string(bytesSplice))
|
||||
default:
|
||||
tmp := fmt.Sprint("shell.Chomp() NO HANDLER FOR TYPE: %T", a)
|
||||
handleError(fmt.Errorf(tmp), -1)
|
||||
log.Printf("shell.Chomp() NEED TO MAKE CONVERTER FOR type =", reflect.TypeOf(t))
|
||||
}
|
||||
tmp := "shell.Chomp() THIS SHOULD NEVER HAPPEN"
|
||||
handleError(fmt.Errorf(tmp), -1)
|
||||
return ""
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package shell
|
||||
|
||||
/*
|
||||
send it anything, always get back an int
|
||||
*/
|
||||
|
||||
// import "log"
|
||||
// import "reflect"
|
||||
// import "strings"
|
||||
// import "bytes"
|
||||
import "strconv"
|
||||
|
||||
func Int(s string) int {
|
||||
s = Chomp(s)
|
||||
i, err := strconv.Atoi(s)
|
||||
if (err != nil) {
|
||||
handleError(err, -1)
|
||||
return 0
|
||||
}
|
||||
return i
|
||||
}
|
Loading…
Reference in New Issue