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/04/13 18:30:40 UTC

[cloudstack-cloudmonkey] 02/05: cli: improve docs output

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 49d5d1ef40375ec4912e12e8af63fe7368b4f434
Author: Rohit Yadav <ro...@apache.org>
AuthorDate: Fri Apr 13 18:22:03 2018 +0530

    cli: improve docs output
    
    Signed-off-by: Rohit Yadav <ro...@apache.org>
---
 cmd/api.go | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/cmd/api.go b/cmd/api.go
index 9dc5c9a..727c3d9 100644
--- a/cmd/api.go
+++ b/cmd/api.go
@@ -48,16 +48,20 @@ func init() {
 
 			api := r.Config.GetCache()[apiName]
 			if api == nil {
-				return errors.New("unknown or unauthorized API: " + apiName)
+				return errors.New("unknown command or API requested")
 			}
 
 			if strings.Contains(strings.Join(apiArgs, " "), "-h") {
 				fmt.Println("=== Help docs ===")
-				fmt.Println(api.Name, ":", api.Description)
-				fmt.Println("Async:", api.Async)
-				fmt.Println("Required params:", strings.Join(api.RequiredArgs, ", "))
+				fmt.Printf("\033[34m%s\033[0m [async=%v] %s\n", api.Name, api.Async, api.Description)
+				if len(api.RequiredArgs) > 0 {
+					fmt.Println("Required params:", strings.Join(api.RequiredArgs, ", "))
+				}
+				if len(api.Args) > 0 {
+					fmt.Println("API params:")
+				}
 				for _, arg := range api.Args {
-					fmt.Println(arg.Name, "(", arg.Type, ")", arg.Description)
+					fmt.Printf("\033[35m%-24s\033[0m \033[36m%-12s\033[0m %s\n", arg.Name, arg.Type, arg.Description)
 				}
 				return nil
 			}

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