Skip to content

Commit ffbc411

Browse files
committed
add call to action if can't find a network
1 parent af1edc4 commit ffbc411

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

packages/cli/src/commands/init.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,14 +422,22 @@ async function processInitForm(
422422
const networkToChoice = (n: Network) => ({
423423
name: n.id,
424424
value: `${n.id}:${n.shortName}:${n.fullName}`.toLowerCase(),
425-
hint: n.id,
425+
hint: ${n.id}`,
426426
message: n.fullName,
427427
});
428428

429429
const formatChoices = (choices: ReturnType<typeof networkToChoice>[]) => {
430430
const shown = choices.slice(0, 20);
431431
const remaining = networks.length - shown.length;
432432
if (remaining == 0) return shown;
433+
if (shown.length === choices.length) {
434+
shown.push({
435+
name: '--other--',
436+
value: '',
437+
hint: '· other network not on the list',
438+
message: `Other`,
439+
});
440+
}
433441
return [
434442
...shown,
435443
{
@@ -477,7 +485,12 @@ async function processInitForm(
477485
.map(networkToChoice)
478486
.filter(({ value }) => (value ?? '').includes(input.toLowerCase())),
479487
),
480-
validate: value => (networks.find(n => n.id === value) ? true : 'Pick a network'),
488+
validate: value => {
489+
if (value === '--other--') {
490+
return 'To add a network refer to https://github.com/graphprotocol/networks-registry';
491+
}
492+
return networks.find(n => n.id === value) ? true : 'Pick a network';
493+
},
481494
result: value => {
482495
initDebugger.extend('processInitForm')('networkId: %O', value);
483496
network = networks.find(n => n.id === value)!;

0 commit comments

Comments
 (0)