@@ -5,6 +5,7 @@ import {ux} from '@oclif/core/ux'
55import _ from 'lodash'
66
77import { formatPrice , formatState , grandfatheredPrice } from '../../lib/addons/util.js'
8+ import { huxTableNoWrapOptions } from '../../lib/utils/tableUtils.js'
89
910const topic = 'addons'
1011
@@ -25,6 +26,7 @@ export default class Addons extends Command {
2526 all : flags . boolean ( { char : 'A' , description : 'show add-ons and attachments for all accessible apps' } ) ,
2627 app : flags . app ( ) ,
2728 json : flags . boolean ( { description : 'return add-ons in json format' } ) ,
29+ 'no-wrap' : flags . noWrap ( ) ,
2830 remote : flags . remote ( ) ,
2931 }
3032
@@ -41,13 +43,13 @@ export default class Addons extends Command {
4143 if ( json )
4244 displayJSON ( addons )
4345 else
44- displayForApp ( app , addons )
46+ displayForApp ( app , addons , flags [ 'no-wrap' ] )
4547 } else {
4648 const addons = await addonGetter ( this . heroku )
4749 if ( json )
4850 displayJSON ( addons )
4951 else
50- displayAll ( addons )
52+ displayAll ( addons , flags [ 'no-wrap' ] )
5153 }
5254 }
5355}
@@ -125,7 +127,7 @@ async function addonGetter(api: APIClient, app?: string) {
125127 return addons
126128}
127129
128- function displayAll ( addons : Heroku . AddOn [ ] ) {
130+ function displayAll ( addons : Heroku . AddOn [ ] , noWrap = false ) {
129131 addons = _ . sortBy ( addons , 'app.name' , 'plan.name' , 'addon.name' )
130132 if ( addons . length === 0 ) {
131133 ux . stdout ( 'No add-ons.' )
@@ -187,14 +189,12 @@ function displayAll(addons: Heroku.AddOn[]) {
187189 } ,
188190 } ,
189191 } ,
190- {
191- overflow : 'wrap' ,
192- } ,
192+ huxTableNoWrapOptions ( noWrap ) ,
193193 )
194194 /* eslint-enable perfectionist/sort-objects */
195195}
196196
197- function displayForApp ( app : string , addons : Heroku . AddOn [ ] ) {
197+ function displayForApp ( app : string , addons : Heroku . AddOn [ ] , noWrap = false ) {
198198 if ( addons . length === 0 ) {
199199 ux . stdout ( `No add-ons for app ${ app } .` )
200200 return
@@ -210,13 +210,16 @@ function displayForApp(app: string, addons: Heroku.AddOn[]) {
210210
211211 const addonLine = `${ service } (${ name } )`
212212 const atts = _ . sortBy ( addon . attachments , isForeignApp , 'app.name' , 'name' )
213- // render each attachment under the add-on
214213 const attLines = atts . map ( ( attachment , idx ) => {
215214 const isLast = ( idx === addon . attachments . length - 1 )
216215 return renderAttachment ( attachment , app , isLast )
217216 } )
218- return [ addonLine ] . concat ( attLines )
219- . join ( '\n' ) + '\n' // Separate each add-on row by a blank line
217+ const lines = [ addonLine , ...attLines ]
218+ if ( noWrap ) {
219+ return lines . join ( ' ' )
220+ }
221+
222+ return `${ lines . join ( '\n' ) } \n`
220223 }
221224
222225 addons = _ . sortBy ( addons , isForeignApp , 'plan.name' , 'name' )
@@ -253,9 +256,7 @@ function displayForApp(app: string, addons: Heroku.AddOn[]) {
253256 get : ( { state} ) => formatState ( state || '' ) ,
254257 } ,
255258 } ,
256- {
257- overflow : 'wrap' ,
258- } ,
259+ huxTableNoWrapOptions ( noWrap ) ,
259260 )
260261 ux . stdout ( `The table above shows add-ons and the attachments to the current app (${ color . app ( app ) } ) or other apps.\n ` )
261262}
0 commit comments