MCPcopy Create free account
hub / github.com/ccxt/ccxt / run

Function run

cli/ts/cli.ts:254–312  ·  view source on GitHub ↗

*

()

Source from the content-addressed store, hash-verified

252 *
253 */
254async function run () {
255 checkCache ();
256
257 const iMode = cliOptions.i;
258
259 while (true) { // main loop, used for the interactive mode
260 if (!methodName) {
261 process.exit (0);
262 }
263
264 const exchange = await loadSettingsAndCreateExchange (exchangeId, cliOptions);
265
266 if (exchange[methodName] === undefined) {
267 log.red (exchange.id + '.' + methodName + ': no such property');
268 process.exit (0);
269 }
270
271 if (typeof exchange[methodName] !== 'function') {
272 printHumanReadable (exchange, exchange[methodName], cliOptions, cliOptions.table);
273 return;
274 }
275
276 let i = 0;
277 const isWsMethod = methodName.startsWith ('watch');
278 try {
279 while (true) { // inner loop used for watchX calls and --poll
280 await executeCCXTCommand (exchange, params, methodName, cliOptions, i);
281 i++;
282
283 if (!isWsMethod && !cliOptions.poll) {
284 break;
285 }
286 }
287 } catch (e) {
288 if (e instanceof ExchangeError) {
289 log.red (e.constructor.name, e.message);
290 } else if (e instanceof NetworkError) {
291 log.yellow (e.constructor.name, e.message);
292 }
293 log.dim ('---------------------------------------------------');
294 // rethrow for call-stack // other errors
295 throw e;
296 }
297
298 if (!iMode) {
299 exchange.close ();
300 break;
301 }
302
303 inputArgs = await askForArgv ('[command]: ');
304
305 // reparse args using the user input
306 program.parse (inputArgs);
307
308 cliOptions = program.opts () as CLIOptions;
309
310 [ exchangeId, methodName, ...params ] = program.args;
311 }

Callers 1

cli.tsFile · 0.70

Calls 7

checkCacheFunction · 0.85
printHumanReadableFunction · 0.85
executeCCXTCommandFunction · 0.85
askForArgvFunction · 0.85
closeMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected