Skip to content

Commit 5e4369b

Browse files
authored
Rename Format -> TableOutput and output -> Format (#5650)
This clarifies the names and keeps them consistent with the table naming.
1 parent c41047e commit 5e4369b

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

ironfish-cli/src/commands/wallet/transactions/index.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { RemoteFlags } from '../../../flags'
1818
import * as ui from '../../../ui'
1919
import { getAssetsByIDs, useAccount } from '../../../utils'
2020
import { extractChainportDataFromTransaction } from '../../../utils/chainport'
21-
import { Format, TableCols } from '../../../utils/table'
21+
import { TableCols, TableOutput } from '../../../utils/table'
2222

2323
const { sort: _, ...tableFlags } = ui.TableFlags
2424

@@ -57,7 +57,7 @@ export class TransactionsCommand extends IronfishCommand {
5757
description: 'Include data from transaction output notes',
5858
}),
5959
format: Flags.string({
60-
description: 'output in a more machine friendly format',
60+
description: 'show the data in a specified view',
6161
exclusive: ['notes'],
6262
options: ['notes', 'transactions', 'transfers'],
6363
helpGroup: 'OUTPUT',
@@ -67,14 +67,14 @@ export class TransactionsCommand extends IronfishCommand {
6767
async start(): Promise<void> {
6868
const { flags } = await this.parse(TransactionsCommand)
6969

70-
const format: Format =
70+
const output: TableOutput =
7171
flags.csv || flags.output === 'csv'
72-
? Format.csv
72+
? TableOutput.csv
7373
: flags.output === 'json'
74-
? Format.json
75-
: Format.cli
74+
? TableOutput.json
75+
: TableOutput.cli
7676

77-
const output =
77+
const format =
7878
flags.notes || flags.format === 'notes'
7979
? 'notes'
8080
: flags.format === 'transactions'
@@ -115,7 +115,7 @@ export class TransactionsCommand extends IronfishCommand {
115115
flags.limit,
116116
flags.offset,
117117
flags.confirmations,
118-
output === 'notes' || output === 'transfers',
118+
format === 'notes' || format === 'transfers',
119119
)
120120

121121
let hasTransactions = false
@@ -126,7 +126,7 @@ export class TransactionsCommand extends IronfishCommand {
126126
break
127127
}
128128

129-
if (output === 'notes' || output === 'transfers') {
129+
if (format === 'notes' || format === 'transfers') {
130130
Assert.isNotUndefined(transaction.notes)
131131

132132
const assetLookup = await getAssetsByIDs(
@@ -148,8 +148,8 @@ export class TransactionsCommand extends IronfishCommand {
148148
assetLookup,
149149
accountsByAddress,
150150
transaction,
151-
format,
152151
output,
152+
format,
153153
),
154154
)
155155
} else {
@@ -160,13 +160,13 @@ export class TransactionsCommand extends IronfishCommand {
160160
flags.confirmations,
161161
)
162162
transactionRows = transactionRows.concat(
163-
this.getTransactionRows(assetLookup, transaction, format),
163+
this.getTransactionRows(assetLookup, transaction, output),
164164
)
165165
}
166166
hasTransactions = true
167167
}
168168

169-
const columns = this.getColumns(flags.extended, output, format)
169+
const columns = this.getColumns(flags.extended, format, output)
170170

171171
ui.table(transactionRows, columns, {
172172
printLine: this.log.bind(this),
@@ -208,7 +208,7 @@ export class TransactionsCommand extends IronfishCommand {
208208
getTransactionRows(
209209
assetLookup: { [key: string]: RpcAsset },
210210
transaction: GetAccountTransactionsResponse,
211-
format: Format,
211+
output: TableOutput,
212212
): PartialRecursive<TransactionRow>[] {
213213
const nativeAssetId = Asset.nativeId().toString('hex')
214214

@@ -233,7 +233,7 @@ export class TransactionsCommand extends IronfishCommand {
233233

234234
// exclude the native asset in cli output if no amount was sent/received
235235
// and it was not the only asset exchanged
236-
if (format === Format.cli && amount === 0n && assetCount > 1) {
236+
if (output === TableOutput.cli && amount === 0n && assetCount > 1) {
237237
assetCount -= 1
238238
continue
239239
}
@@ -251,7 +251,7 @@ export class TransactionsCommand extends IronfishCommand {
251251
}
252252

253253
// include full transaction details in first row or non-cli-formatted output
254-
if (transactionRows.length === 0 || format !== Format.cli) {
254+
if (transactionRows.length === 0 || output !== TableOutput.cli) {
255255
transactionRows.push({
256256
...transaction,
257257
...transactionRow,
@@ -269,8 +269,8 @@ export class TransactionsCommand extends IronfishCommand {
269269
assetLookup: { [key: string]: RpcAsset },
270270
accountLookup: Map<string, string>,
271271
transaction: GetAccountTransactionsResponse,
272-
format: Format,
273-
output: 'notes' | 'transactions' | 'transfers',
272+
output: TableOutput,
273+
format: 'notes' | 'transactions' | 'transfers',
274274
): PartialRecursive<TransactionRow>[] {
275275
Assert.isNotUndefined(transaction.notes)
276276
const transactionRows = []
@@ -297,7 +297,7 @@ export class TransactionsCommand extends IronfishCommand {
297297

298298
let group = this.getRowGroup(index, noteCount, transactionRows.length)
299299

300-
if (output === 'transfers') {
300+
if (format === 'transfers') {
301301
if (note.sender === note.owner && !transaction.mints.length) {
302302
continue
303303
} else {
@@ -306,7 +306,7 @@ export class TransactionsCommand extends IronfishCommand {
306306
}
307307

308308
// include full transaction details in first row or non-cli-formatted output
309-
if (transactionRows.length === 0 || format !== Format.cli) {
309+
if (transactionRows.length === 0 || output !== TableOutput.cli) {
310310
transactionRows.push({
311311
...transaction,
312312
group,
@@ -345,7 +345,7 @@ export class TransactionsCommand extends IronfishCommand {
345345
getColumns(
346346
extended: boolean,
347347
output: 'notes' | 'transactions' | 'transfers',
348-
format: Format,
348+
format: TableOutput,
349349
): ui.TableColumns<PartialRecursive<TransactionRow>> {
350350
let columns: ui.TableColumns<PartialRecursive<TransactionRow>> = {
351351
timestamp: TableCols.timestamp({
@@ -443,7 +443,7 @@ export class TransactionsCommand extends IronfishCommand {
443443
}
444444
}
445445

446-
if (format === Format.cli) {
446+
if (format === TableOutput.cli) {
447447
columns = {
448448
group: {
449449
header: '',

ironfish-cli/src/ui/table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const TableFlags = {
4848
helpGroup: 'OUTPUT',
4949
}),
5050
output: Flags.string({
51-
description: 'output in a more machine friendly format',
51+
description: 'output in different file types',
5252
exclusive: ['csv'],
5353
options: ['csv', 'json'],
5454
helpGroup: 'OUTPUT',

ironfish-cli/src/utils/table.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ const timestamp = <T extends Record<string, unknown>>(options?: {
6161

6262
const asset = <T extends Record<string, unknown>>(options?: {
6363
extended?: boolean
64-
format?: Format
64+
format?: TableOutput
6565
}): Partial<Record<string, TableColumn<T>>> => {
66-
if (options?.extended || options?.format !== Format.cli) {
66+
if (options?.extended || options?.format !== TableOutput.cli) {
6767
return {
6868
assetId: {
6969
header: 'Asset ID',
@@ -127,7 +127,7 @@ function truncateCol(value: string, maxWidth: number | null): string {
127127
return value.slice(0, maxWidth - 1) + '…'
128128
}
129129

130-
export enum Format {
130+
export enum TableOutput {
131131
cli = 'cli',
132132
csv = 'csv',
133133
json = 'json',

0 commit comments

Comments
 (0)