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 2023/08/03 06:32:16 UTC

[cloudstack-cloudmonkey] branch main updated: cmk: don't print discovered apis message in cmd line mode

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

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


The following commit(s) were added to refs/heads/main by this push:
     new e3e577c  cmk: don't print discovered apis message in cmd line mode
e3e577c is described below

commit e3e577cf3adca2cc35fcdd7bd95ccdc5c36c3b8d
Author: Rohit Yadav <ro...@shapeblue.com>
AuthorDate: Thu Aug 3 11:56:57 2023 +0530

    cmk: don't print discovered apis message in cmd line mode
    
    This avoids printing message in cmd line mode, where output of the cmk
    command may be processed by a shell script.
    
    Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
---
 cmk.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmk.go b/cmk.go
index 98d2027..9ef24ed 100644
--- a/cmk.go
+++ b/cmk.go
@@ -51,6 +51,7 @@ func main() {
 	apiKey := flag.String("k", "", "cloudStack user's API Key")
 	secretKey := flag.String("s", "", "cloudStack user's secret Key")
 	flag.Parse()
+	args := flag.Args()
 
 	cfg := config.NewConfig(configFilePath)
 
@@ -91,14 +92,13 @@ func main() {
 	if *apiKey != "" && *secretKey != "" {
 		request := cmd.NewRequest(nil, cfg, nil)
 		syncResponse, err := cmd.NewAPIRequest(request, "listApis", []string{"listall=true"}, false)
-		if err == nil {
+		if err == nil && len(args) == 0 {
 			fmt.Printf("Discovered %v APIs\n", cfg.UpdateCache(syncResponse))
 		}
 	}
 
 	cli.SetConfig(cfg)
 
-	args := flag.Args()
 	config.Debug("cmdline args:", strings.Join(os.Args, ", "))
 	if len(args) > 0 {
 		if err := cli.ExecCmd(args); err != nil {