Skip to content

Commit cc123e9

Browse files
committed
improve init prompt wording
1 parent ea8c867 commit cc123e9

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

packages/cli/src/commands/init.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs';
22
import os from 'os';
33
import path from 'path';
4-
import { filesystem, prompt, system } from 'gluegun';
4+
import { filesystem, print, prompt, system } from 'gluegun';
55
import { Args, Command, Flags } from '@oclif/core';
66
import { Network, NetworksRegistry } from '@pinax/graph-networks-registry';
77
import { appendApiVersionForGraph } from '../command-helpers/compiler.js';
@@ -434,7 +434,7 @@ async function processInitForm(
434434
name: ``,
435435
disabled: true,
436436
hint: '',
437-
message: ` < ${remaining} more >`,
437+
message: `< ${remaining} more - start typing to filter >`,
438438
},
439439
];
440440
};
@@ -463,7 +463,12 @@ async function processInitForm(
463463
required: true,
464464
message: 'Network',
465465
choices: formatChoices(networks.map(networkToChoice)),
466-
format: value => `${value}`,
466+
format: value => {
467+
const network = networks.find(n => n.id === value);
468+
return network
469+
? `${network.fullName}${print.colors.muted(` · ${network.id} · ${network.explorerUrls?.[0] ?? ''}`)}`
470+
: value;
471+
},
467472
suggest: (input, _) =>
468473
formatChoices(
469474
networks
@@ -497,7 +502,7 @@ async function processInitForm(
497502
choices: [
498503
{ message: 'Substreams', name: 'substreams', value: 'substreams' },
499504
{ message: 'Subgraph', name: 'subgraph', value: 'subgraph' },
500-
].filter(({ name }) => name),
505+
],
501506
validate: name => {
502507
if (name === 'arweave') {
503508
return 'Arweave are only supported via substreams';
@@ -507,6 +512,18 @@ async function processInitForm(
507512
}
508513
return true;
509514
},
515+
format: protocol => {
516+
switch (protocol) {
517+
case '':
518+
return '';
519+
case 'substreams':
520+
return 'Substreams';
521+
case 'subgraph':
522+
return 'Subgraph';
523+
default:
524+
return `Smart Contract${print.colors.muted(` · ${protocol}`)}`;
525+
}
526+
},
510527
result: protocol => {
511528
protocolInstance = new Protocol(protocol);
512529
isComposedSubgraph = protocolInstance.isComposedSubgraph();

0 commit comments

Comments
 (0)