dubeejw commented on a change in pull request #2326: (Review) Alphabetize
URL: 
https://github.com/apache/incubator-openwhisk/pull/2326#discussion_r124100866
 
 

 ##########
 File path: tools/cli/go-whisk/whisk/api.go
 ##########
 @@ -196,12 +221,97 @@ var ApiVerbs map[string]bool = map[string]bool {
 const (
     Overwrite = true
     DoNotOverwrite = false
+    sortActionFlag = "a"
 )
 
 ////////////////////
 // Api Methods //
 ////////////////////
 
+/*
+ *  Compare(s) compares ApiFilteredList api to Sortable s for the purpose of
+ *    sorting.
+ *  params: Sortable type s that is also of type ApiFilteredList (REQUIRED)
+ *  ***Method of type Sortable***
+ *  ***By default, sorts Alphabetically***
+ */
+func(api ApiFilteredList) Compare(sortable Sortable) bool{
+  // convert s back to proper type
+  apiToCompare := sortable.(ApiFilteredList)
+  var apiString string
+  var compareString string
+
+  // Check for flag to build proper comparison strings
+  switch api.Flag {
+  case sortActionFlag:
+      apiString = strings.ToLower(fmt.Sprintf("%s%s%s%s", api.ActionName,
+          api.BasePath, api.RelPath, api.Verb))
+      compareString = strings.ToLower(fmt.Sprintf("%s%s%s%s", 
apiToCompare.ActionName,
+          apiToCompare.BasePath, apiToCompare.RelPath, apiToCompare.Verb))
+  default:
+      apiString = strings.ToLower(fmt.Sprintf("%s%s%s",api.BasePath, 
api.RelPath,
+          api.Verb))
+      compareString = strings.ToLower(fmt.Sprintf("%s%s%s", 
apiToCompare.BasePath,
+          apiToCompare.RelPath, apiToCompare.Verb))
+  }
+
+  return apiString < compareString
+}
+
+/*
+ *  InfoToString() returns a compound string of required parameters for 
printing
+ *    from CLI command `wsk api list` or `wsk api-experimental list`.
+ *  ***Method of type Sortable***
+ */
+func(api ApiFilteredList) InfoToString() string {
+    return fmt.Sprintf("%s %s %s %s %s %s",
+    fmt.Sprintf("%s: %s\n", wski18n.T("Action"), api.ActionName),
 
 Review comment:
   I think all these `fmt` calls need to be indented one more tab.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to