Skip to content

Commit

Permalink
feat: send message to display in each call of prompt (more flexible)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoSerranoP committed Apr 9, 2024
1 parent eb6b176 commit 625dddc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
6 changes: 5 additions & 1 deletion packages/phase2cli/src/commands/contribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,11 @@ const contribute = async (opt: any) => {
} else selectedCeremony = selectedCeremonyDocument.at(0)
} else {
// Prompt the user to select a ceremony from the opened ones.
selectedCeremony = await promptForCeremonySelection(ceremoniesOpenedForContributions, false)
selectedCeremony = await promptForCeremonySelection(
ceremoniesOpenedForContributions,
false,
"Which ceremony would you like to contribute to?"
)
}

// Get selected ceremony circuit(s) documents.
Expand Down
6 changes: 5 additions & 1 deletion packages/phase2cli/src/commands/finalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ const finalize = async (opt: any) => {
)

// Prompt for ceremony selection.
const selectedCeremony = await promptForCeremonySelection(ceremoniesClosedForFinalization, true)
const selectedCeremony = await promptForCeremonySelection(
ceremoniesClosedForFinalization,
true,
"Which ceremony would you like to finalize?"
)

// Get coordinator participant document.
let participant = await getDocumentById(
Expand Down
6 changes: 5 additions & 1 deletion packages/phase2cli/src/commands/observe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ const observe = async () => {
const runningCeremoniesDocs = await getOpenedCeremonies(firestoreDatabase)

// Ask to select a ceremony.
const ceremony = await promptForCeremonySelection(runningCeremoniesDocs, false)
const ceremony = await promptForCeremonySelection(
runningCeremoniesDocs,
false,
"Which ceremony would you like to observe?"
)

console.log(`${logSymbols.info} Refresh rate set to ~3 seconds for waiting queue updates\n`)

Expand Down
9 changes: 3 additions & 6 deletions packages/phase2cli/src/lib/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ export const promptPotSelector = async (options: Array<string>): Promise<string>
*/
export const promptForCeremonySelection = async (
ceremoniesDocuments: Array<FirebaseDocumentInfo>,
isFinalizing: boolean
isFinalizing: boolean,
messageToDisplay?: string
): Promise<FirebaseDocumentInfo> => {
// Prepare state.
const choices: Array<Choice> = []
Expand All @@ -686,11 +687,7 @@ export const promptForCeremonySelection = async (
const { ceremony } = await prompts({
type: "select",
name: "ceremony",
message: theme.text.bold(
!isFinalizing
? "Which ceremony would you like to contribute to?"
: "Which ceremony would you like to finalize?"
),
message: theme.text.bold(messageToDisplay),
choices,
initial: 0
})
Expand Down

0 comments on commit 625dddc

Please sign in to comment.