Skip to content

Commit 2011a43

Browse files
committed
Adding csv option to targets
1 parent 73d94c5 commit 2011a43

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

bin.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,23 @@ program
131131
.description('Get deployed target files for an environment')
132132
.option('-n, --network <value>', 'The network to run off.', x => x.toLowerCase(), 'mainnet')
133133
.option('-c, --contract [value]', 'The name of the contract')
134-
.option('-k, --key [value]', 'A specific key wanted')
134+
.option('-k, --key [value]', 'A specific key wanted (ignored when using csv)')
135+
.option('-v, --csv', 'Whether or not to CSV output the results')
135136
.option('-z, --use-ovm', 'Target deployment for the OVM (Optimism).')
136-
.action(async ({ network, useOvm, contract, key }) => {
137+
.action(async ({ network, useOvm, contract, key, csv }) => {
137138
const target = getTarget({ network, useOvm, contract });
138-
console.log(JSON.stringify(key in target ? target[key] : target, null, 2));
139+
if (csv) {
140+
let headerComplete;
141+
for (const entry of Object.values(target)) {
142+
if (!headerComplete) {
143+
console.log(Object.keys(entry).join(','));
144+
headerComplete = true;
145+
}
146+
console.log(Object.values(entry).join(','));
147+
}
148+
} else {
149+
console.log(JSON.stringify(key in target ? target[key] : target, null, 2));
150+
}
139151
});
140152

141153
program

0 commit comments

Comments
 (0)