summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralabid <alabidan@gmail.com>2014-10-21 14:59:14 -0400
committeralabid <alabidan@gmail.com>2014-10-21 15:00:10 -0400
commit35f9bdfbeea81c4aeaa670852cd6ed065c7d073a (patch)
tree54f7bb0a9ed9ca24f494d14e25483be670aa11cb
parent4a7aaad331daf81acf0b02de6c9b3a3b49320fd4 (diff)
downloadmongo-35f9bdfbeea81c4aeaa670852cd6ed065c7d073a.tar.gz
mongofiles: display url after session init; only display port when user-specified
Former-commit-id: ce96319c51c27dfba62b745867cc464ad4e36fa0
-rw-r--r--mongofiles/mongofiles.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/mongofiles/mongofiles.go b/mongofiles/mongofiles.go
index b9d2b77c569..c59b6c2eab6 100644
--- a/mongofiles/mongofiles.go
+++ b/mongofiles/mongofiles.go
@@ -177,17 +177,12 @@ func (self *MongoFiles) handlePut(gfs *mgo.GridFS) (string, error) {
// Run the mongofiles utility
func (self *MongoFiles) Run(displayConnUrl bool) (string, error) {
- if displayConnUrl {
- connHost := self.ToolOptions.Host
- if connHost == "" {
- connHost = util.DefaultHost
- }
- connPort := self.ToolOptions.Port
- if connPort == "" {
- connPort = util.DefaultPort
- }
-
- fmt.Printf("connected to: %v\n", fmt.Sprintf("%s:%s", connHost, connPort))
+ connUrl := self.ToolOptions.Host
+ if connUrl == "" {
+ connUrl = util.DefaultHost
+ }
+ if self.ToolOptions.Port != "" {
+ connUrl = fmt.Sprintf("%s:%s", connUrl, self.ToolOptions.Port)
}
// get session
@@ -198,6 +193,10 @@ func (self *MongoFiles) Run(displayConnUrl bool) (string, error) {
defer session.Close()
session.SetSocketTimeout(0)
+ if displayConnUrl {
+ fmt.Printf("connected to: %v\n", connUrl)
+ }
+
if self.ToolOptions.Namespace.DB == "" {
self.ToolOptions.Namespace.DB = "test"
}