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

 ##########
 File path: tools/cli/go-whisk/whisk/trigger.go
 ##########
 @@ -46,6 +46,36 @@ type TriggerListOptions struct {
     Docs            bool            `url:"docs,omitempty"`
 }
 
+/*
+ *  Compare(s) compares Trigger t to Sortable s for the purpose of sorting.
+ *  params: Sortable type s that is also of type Trigger (REQUIRED)
+ *  ***Method of type Sortable***
+ *  ***By default, sorts Alphabetically***
+ */
+func(trigger Trigger) Compare(sortable Sortable) bool {
+    // convert s back to proper type
+    triggerToCompare := sortable.(Trigger)
+    triggerString := strings.ToLower(fmt.Sprintf("%s%s",trigger.Namespace,
+        trigger.Name))
+    compareString := strings.ToLower(fmt.Sprintf("%s%s", 
triggerToCompare.Namespace,
+        triggerToCompare.Name))
+
+    return triggerString < compareString
+}
+
+/*
+ *  ListString() returns a compound string of required parameters for printing
+ *    from CLI command `wsk trigger list`.
+ *  ***Method of type Sortable***
+ */
+func(trigger Trigger) ListString() string {
+    publishState := wski18n.T("private")
+
+    return fmt.Sprintf("%-70s %s\n", fmt.Sprintf("/%s/%s", trigger.Namespace,
+        trigger.Name), publishState)
+
 
 Review comment:
   Delete new line here.
 
----------------------------------------------------------------
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