This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack-cloudmonkey.git

commit 88fcf8fe17735eb8a29613f228960815c189550b
Author: Rohit Yadav <ro...@apache.org>
AuthorDate: Sat Apr 14 03:35:58 2018 +0530

    prompt: emoji-roulette on new shell
    
    Signed-off-by: Rohit Yadav <ro...@apache.org>
---
 cli/shell.go     |  1 +
 config/config.go |  2 --
 config/prompt.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/cli/shell.go b/cli/shell.go
index 1dfc075..903a607 100644
--- a/cli/shell.go
+++ b/cli/shell.go
@@ -57,6 +57,7 @@ func ExecShell(cfg *config.Config) {
        cfg.PrintHeader()
 
        for {
+               shell.SetPrompt(cfg.GetPrompt())
                line, err := shell.Readline()
                if err == readline.ErrInterrupt {
                        continue
diff --git a/config/config.go b/config/config.go
index b89cc54..e5336e5 100644
--- a/config/config.go
+++ b/config/config.go
@@ -151,8 +151,6 @@ func reloadConfig(cfg *Config) *Config {
        }
        // Save
        conf.SaveTo(cfg.ConfigFile)
-
-       fmt.Println("Updating config to:", cfg.Core, cfg.Core.ActiveProfile)
        return cfg
 }
 
diff --git a/config/prompt.go b/config/prompt.go
new file mode 100644
index 0000000..ea8dd82
--- /dev/null
+++ b/config/prompt.go
@@ -0,0 +1,48 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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 config
+
+import (
+       "fmt"
+       "math/rand"
+       "runtime"
+       "strings"
+       "time"
+)
+
+var emojis []string
+
+func init() {
+       rand.Seed(time.Now().Unix())
+       emojis = strings.Split("🐶 🐹 🐰 🐻 🐼 🐨 🐯 🦁 🐷 🐙 🙈 🙉 🙊 🐒 🐔 🐧 🐦 🐤 🐣 🐥 🐺 🐗 🐴 🦄 
🐝 🐛 🐌 🐞 🐜 🕷 🦂 🦀 🐍 🐢 🐠 🐟 🐡 🐬 🐳 🐋 🐅 🐃 🐂 🐄 🐘 🐐 🐑 🐎 🐖 🐀 🐓 🦃 🕊 🐕 🐩 🐈 🐇 🐿  🐲 🌵 🦍 🦊 🦌 
🦏 🦇 🦅 🦆 🦉 🦈 🦐 🦑 🦋 🌴 🍀 🍂 🍁 🍄 🌍 ⛅️", " ")
+}
+
+func emoji() string {
+       return emojis[rand.Intn(len(emojis)-1)]
+}
+
+func promptMoji() string {
+       if runtime.GOOS == "windows" {
+               return "cmk"
+       }
+       return emoji() // 🐒
+}
+
+func (c *Config) GetPrompt() string {
+       return fmt.Sprintf("(%s) %s > ", c.Core.ProfileName, promptMoji())
+}

-- 
To stop receiving notification emails like this one, please contact
ro...@apache.org.

Reply via email to