class Cli {
  constructor (JiraApi, TableRenderer, Logger) {
    this.api = JiraApi
    this.tableRenderer = TableRenderer
    this.logger = Logger
  }

  renderIssue (issue) {
    return this.api
      .getIssue((issue))
      .then((issue) => {
        this.tableRenderer.renderTitle('Issue detail summary')
        this.tableRenderer.renderVertical([
          {'Key': issue.key},
          {'Issue Type': issue.type},
          {'Summary': issue.summary},
          {'Status': issue.status},
          {'Project': issue.projectName + ' (' + issue.projectKey + ')'}
        ])
      })
      .catch((error) => {
        this.logger.error(error.toString())
      })
  }

  renderIssues (options) {
    return this.api
      .getIssues(options)
      .then((issues) => {
        let head = ['Issue key', 'Status', 'Summary', 'Project key']
        let rows = []
        issues.map((issue) => {
          rows.push([
            issue.key,
            issue.status,
            issue.summary,
            issue.projectKey
          ])
        })
        this.tableRenderer.render(head, rows)
      })
      .catch((error) => {
        this.logger.error(error.toString())
      })
  }

  renderTransitions (options) {
    return this.api
      .getTransitions(options.key)
      .then((transitions) => {
        let head = ['Id', 'Name']
        let rows = []
        transitions.map((transition) => {
          rows.push([
            transition.id,
            transition.name
          ])
        })
        this.tableRenderer.render(head, rows)
      })
      .catch((error) => {
        this.logger.error(error.toString())
      })
  }

  transitionIssue (issue, status) {
    return this.api
      .transitionIssue(issue, status)
      .then((response) => {
        this.logger.success('Issue ' + issue + ' transitioned to ' + status + ' status')
      })
      .catch((error) => {
        this.logger.error(error.toString())
      })
  }

  addComment (issue, comment) {
    return this.api
      .addComment(issue, comment)
      .then((response) => {
        this.logger.success('Comment added to issue ' + issue)
      })
      .catch((error) => {
        this.logger.error(error.toString())
      })
  }

  addWorklog (issue, timeSpent, comment) {
    return this.api
      .addWorklog(issue, timeSpent, comment)
      .then((response) => {
        this.logger.success('Worklog ' + timeSpent + ' added to issue ' + issue)
      })
      .catch((error) => {
        this.logger.error(error.toString())
      })
  }

  renderIssueWorklogs (issue) {
    return this.api
      .getIssueWorklogs(issue)
      .then((worklogs) => {
        let head = ['Worklog Id', 'Timespent', 'Comment', 'Author', 'Created']
        let rows = []
        worklogs.map((worklog) => {
          rows.push([
            worklog.id,
            worklog.timeSpent,
            worklog.comment,
            worklog.author,
            worklog.created.split('T')[0]
          ])
        })
        this.tableRenderer.render(head, rows)
      })
      .catch((error) => {
        this.logger.error(error.message)
      })
  }
}

module.exports = (JiraApi, TableRenderer, Logger) => (new Cli(JiraApi, TableRenderer, Logger))

@@ -769,34 +769,60 @@
 %3E %7B%0A        
-let head =
+this.tableRenderer.render(%0A         
  %5B'Issue key
@@ -859,39 +859,20 @@
 ct key'%5D
+,
 %0A  
-      let rows = %5B%5D%0A
         
@@ -909,54 +909,28 @@
     
-rows.push(%5B%0A            issue.key,%0A           
+  return %5Bissue.key,
  iss
@@ -939,28 +939,16 @@
 .status,
-%0A           
  issue.s
@@ -954,28 +954,16 @@
 summary,
-%0A           
  issue.p
@@ -971,30 +971,20 @@
 ojectKey
+%5D
 %0A
- 
   
-       %5D)%0A
         
@@ -998,44 +998,8 @@
     
-this.tableRenderer.render(head, rows
 )%0A  
@@ -1215,26 +1215,52 @@
         
-let head =
+this.tableRenderer.render(%0A         
  %5B'Id', 
@@ -1266,39 +1266,20 @@
  'Name'%5D
+,
 %0A  
-      let rows = %5B%5D%0A
         
@@ -1326,32 +1326,18 @@
     
-rows.push(%5B%0A            
+  return %5B
 tran
@@ -1346,28 +1346,16 @@
 tion.id,
-%0A           
  transit
@@ -1362,38 +1362,28 @@
 ion.name
+%5D
 %0A
-    
      
- %5D)%0A
      
-   
 %7D)%0A     
@@ -1389,44 +1389,8 @@
     
-this.tableRenderer.render(head, rows
 )%0A  
@@ -2487,18 +2487,44 @@
     
-let head =
+this.tableRenderer.render(%0A         
  %5B'W
@@ -2583,31 +2583,12 @@
 ed'%5D
+,
 %0A  
-      let rows = %5B%5D%0A
     
@@ -2633,20 +2633,21 @@
     
-rows.push(%5B%0A
+  return %5B%0A  
     
@@ -2670,32 +2670,34 @@
 id,%0A            
+  
 worklog.timeSpen
@@ -2695,24 +2695,26 @@
 .timeSpent,%0A
+  
             
@@ -2734,32 +2734,34 @@
 nt,%0A            
+  
 worklog.author,%0A
@@ -2760,16 +2760,18 @@
 author,%0A
+  
         
@@ -2810,27 +2810,30 @@
 %5D%0A          
-%5D)%0A
+  %5D%0A  
         %7D)%0A 
@@ -2843,44 +2843,8 @@
     
-this.tableRenderer.render(head, rows
 )%0A  

Remove un necessary variables