From 6ee8d8a8999e745f480f5fe6a99a41d0a68ea025 Mon Sep 17 00:00:00 2001 From: Matthew Yarmolinsky Date: Wed, 20 Jul 2022 16:34:50 +0000 Subject: [PATCH] fleet: Use the oclif output formatter Change-type: major Signed-off-by: Matthew Yarmolinsky --- lib/commands/fleet/index.ts | 25 ++++++------------------ lib/commands/fleets.ts | 39 +++++++++++++------------------------ 2 files changed, 19 insertions(+), 45 deletions(-) diff --git a/lib/commands/fleet/index.ts b/lib/commands/fleet/index.ts index 38aa124d..a7b99f37 100644 --- a/lib/commands/fleet/index.ts +++ b/lib/commands/fleet/index.ts @@ -22,7 +22,7 @@ import type { Release } from 'balena-sdk'; import Command from '../../command'; import * as cf from '../../utils/common-flags'; import * as ca from '../../utils/common-args'; -import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy'; +import { getBalenaSdk, stripIndent } from '../../utils/lazy'; import { applicationIdInfo } from '../../utils/messages'; import { isV14 } from '../../utils/version'; import type { DataOutputOptions } from '../../framework'; @@ -99,23 +99,10 @@ export default class FleetCmd extends Command { application.device_type = application.is_for__device_type[0].slug; application.commit = application.should_be_running__release[0]?.commit; - if (isV14()) { - await this.outputData( - application, - ['app_name', 'id', 'device_type', 'slug', 'commit'], - options, - ); - } else { - // Emulate table.vertical title output, but avoid uppercasing and inserting spaces - console.log(`== ${application.slug}`); - console.log( - getVisuals().table.vertical(application, [ - 'id', - 'device_type', - 'slug', - 'commit', - ]), - ); - } + await this.outputData( + application, + ['app_name', 'id', 'device_type', 'slug', 'commit'], + options, + ); } } diff --git a/lib/commands/fleets.ts b/lib/commands/fleets.ts index 04a6cd28..cc0276a2 100644 --- a/lib/commands/fleets.ts +++ b/lib/commands/fleets.ts @@ -19,7 +19,7 @@ import { flags } from '@oclif/command'; import Command from '../command'; import * as cf from '../utils/common-flags'; -import { getBalenaSdk, getVisuals, stripIndent } from '../utils/lazy'; +import { getBalenaSdk, stripIndent } from '../utils/lazy'; import { isV14 } from '../utils/version'; import type { DataSetOutputOptions } from '../framework'; @@ -79,30 +79,17 @@ export default class FleetsCmd extends Command { application.device_type = application.is_for__device_type[0].slug; }); - if (isV14()) { - await this.outputData( - applications, - [ - 'id', - 'app_name', - 'slug', - 'device_type', - 'device_count', - 'online_devices', - ], - options, - ); - } else { - console.log( - getVisuals().table.horizontal(applications, [ - 'id', - 'app_name => NAME', - 'slug', - 'device_type', - 'online_devices', - 'device_count', - ]), - ); - } + await this.outputData( + applications, + [ + 'id', + 'app_name', + 'slug', + 'device_type', + 'device_count', + 'online_devices', + ], + options, + ); } }