You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2018/05/04 11:50:37 UTC

[cloudstack-cloudmonkey] branch master updated (463384e -> 17561b6)

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

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


    from 463384e  vendor: add missing go-runewidth dependency
     new 7e2aae2  config: allow custom prompt
     new 17561b6  api: fix linting issue and order by filter keys

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 cmd/api.go       | 14 ++++++++------
 cmd/set.go       |  1 +
 config/cache.go  |  1 +
 config/config.go |  4 ++++
 config/prompt.go |  9 ++++++---
 5 files changed, 20 insertions(+), 9 deletions(-)

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

[cloudstack-cloudmonkey] 01/02: config: allow custom prompt

Posted by ro...@apache.org.
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 7e2aae2acca8f946d59ac7853e0090efe332da01
Author: Rohit Yadav <ro...@apache.org>
AuthorDate: Fri May 4 17:19:48 2018 +0530

    config: allow custom prompt
    
    Signed-off-by: Rohit Yadav <ro...@apache.org>
---
 cmd/set.go       | 1 +
 config/cache.go  | 1 +
 config/config.go | 4 ++++
 config/prompt.go | 9 ++++++---
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/cmd/set.go b/cmd/set.go
index 961decb..1755227 100644
--- a/cmd/set.go
+++ b/cmd/set.go
@@ -27,6 +27,7 @@ func init() {
 		Name: "set",
 		Help: "Configures options for cmk",
 		SubCommands: map[string][]string{
+			"prompt":     {"🐵", "random"},
 			"asyncblock": {"true", "false"},
 			"timeout":    {"600", "1800", "3600"},
 			"output":     {"json", "text", "table", "xml"},
diff --git a/config/cache.go b/config/cache.go
index 8fc9089..a40fdf5 100644
--- a/config/cache.go
+++ b/config/cache.go
@@ -26,6 +26,7 @@ import (
 	"unicode"
 )
 
+// FAKE is used for fake CLI only options like filter=
 const FAKE = "fake"
 
 // APIArg are the args passable to an API
diff --git a/config/config.go b/config/config.go
index 16bda15..046f134 100644
--- a/config/config.go
+++ b/config/config.go
@@ -48,6 +48,7 @@ type ServerProfile struct {
 
 // Core block describes common options for the CLI
 type Core struct {
+	Prompt      string `ini:"prompt"`
 	AsyncBlock  bool   `ini:"asyncblock"`
 	Timeout     int    `ini:"timeout"`
 	Output      string `ini:"output"`
@@ -76,6 +77,7 @@ func getDefaultConfigDir() string {
 
 func defaultCoreConfig() Core {
 	return Core{
+		Prompt:      "🐵",
 		AsyncBlock:  false,
 		Timeout:     1800,
 		Output:      JSON,
@@ -194,6 +196,8 @@ func reloadConfig(cfg *Config) *Config {
 // UpdateConfig updates and saves config
 func (c *Config) UpdateConfig(key string, value string) {
 	switch key {
+	case "prompt":
+		c.Core.Prompt = value
 	case "asyncblock":
 		c.Core.AsyncBlock = value == "true"
 	case "output":
diff --git a/config/prompt.go b/config/prompt.go
index 83b04b1..fe002d1 100644
--- a/config/prompt.go
+++ b/config/prompt.go
@@ -36,14 +36,17 @@ func emoji() string {
 	return emojis[rand.Intn(len(emojis)-1)]
 }
 
-func promptMoji() string {
+func renderPrompt(prompt string) string {
 	if runtime.GOOS == "windows" {
 		return "cmk"
 	}
-	return emoji() // 🐒
+	if prompt == "random" {
+		return emoji()
+	}
+	return prompt
 }
 
 // GetPrompt returns prompt that the CLI should use
 func (c *Config) GetPrompt() string {
-	return fmt.Sprintf("(%s) %s > ", c.Core.ProfileName, promptMoji())
+	return fmt.Sprintf("(%s) %s > ", c.Core.ProfileName, renderPrompt(c.Core.Prompt))
 }

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

[cloudstack-cloudmonkey] 02/02: api: fix linting issue and order by filter keys

Posted by ro...@apache.org.
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 17561b66f41511e8418ea264ee732fea687e5b75
Author: Rohit Yadav <ro...@apache.org>
AuthorDate: Fri May 4 17:20:12 2018 +0530

    api: fix linting issue and order by filter keys
    
    Signed-off-by: Rohit Yadav <ro...@apache.org>
---
 cmd/api.go | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/cmd/api.go b/cmd/api.go
index c13a2c8..ba7b70d 100644
--- a/cmd/api.go
+++ b/cmd/api.go
@@ -79,18 +79,20 @@ func printResult(outputType string, response map[string]interface{}, filter []st
 					}
 
 					if len(header) == 0 {
-						for field, _ := range row {
-							if filter != nil && len(filter) > 0 {
-								for _, filterKey := range filter {
+						if filter != nil && len(filter) > 0 {
+							for _, filterKey := range filter {
+								for field := range row {
 									if filterKey == field {
 										header = append(header, field)
 									}
 								}
-								continue
 							}
-							header = append(header, field)
+						} else {
+							for field := range row {
+								header = append(header, field)
+							}
+							sort.Strings(header)
 						}
-						sort.Strings(header)
 						table.SetHeader(header)
 					}
 					var rowArray []string

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