@kadena/kadena-cli
Version:
Kadena CLI tool to interact with the Kadena blockchain (manage keys, transactions, etc.)
148 lines • 4.76 kB
JavaScript
import { input } from '../utils/prompts.js';
export const cleanPrompt = async () => {
const response = await input({
message: 'Would you like to clean existing generated files? (yes/no)',
validate: (input) => {
if (input.toLowerCase() === 'yes' || input.toLowerCase() === 'no') {
return true;
}
return 'Please enter "yes" or "no"';
},
});
return response.toLowerCase().trim();
};
export const capsInterfacePrompt = async () => {
const response = await input({
message: 'Enter a custom name for the interface of the caps (optional):',
});
if (response.trim().length === 0) {
return '';
}
return response;
};
export const fileOrDirectoryPrompt = async (previousQuestions, args, isOptional) => {
const response = await input({
message: 'Enter the file(s) or directory to generate the client from, separated by commas:',
validate: (input) => {
if (input.trim().length === 0 && !isOptional) {
return 'Please enter at least one file path or directory';
}
return true;
},
});
if (response.trim().length === 0 && isOptional) {
return '';
}
return response;
};
export const filePrompt = async (previousQuestions, args, isOptional) => {
if (Array.isArray(previousQuestions.contract) &&
previousQuestions.contract.length === 0) {
return '';
}
const response = await input({
message: 'Enter the file(s) to generate d.ts from, separated by commas: (optional)',
validate: (input) => {
if (input.trim().length === 0 && !isOptional) {
return 'Please enter at least one file path';
}
return true;
},
});
if (response.trim().length === 0 && isOptional) {
return '';
}
return response;
};
export const contractPrompt = async (previousQuestions, args) => {
if (Array.isArray(previousQuestions.file) &&
previousQuestions.file.length === 0) {
return '';
}
const response = await input({
message: 'Enter the contract(s) to generate d.ts from the blockchain, separated by commas:',
validate: (input) => {
if (input.trim().length === 0) {
return 'Please enter at least one contract name';
}
return true;
},
});
return response;
};
export const apiPrompt = async (previousQuestions, args, isOptional) => {
const response = await input({
message: 'Enter the API to use for retrieving the contract (optional):',
validate: (input) => {
if (input.trim().length === 0 && !isOptional) {
return 'Please enter an API';
}
return true;
},
});
if (response.trim().length === 0 && isOptional) {
return '';
}
return response;
};
export const modulePrompt = async () => {
const response = await input({
message: 'Enter the module you want to retrieve (e.g. "coin"):',
validate: (input) => {
if (input.trim().length === 0) {
return 'Please enter the module name';
}
return true;
},
});
return response.trim();
};
export const outPrompt = async () => {
const response = await input({
message: 'Enter file to write the contract to:',
validate: (input) => {
if (input.trim().length === 0) {
return 'Please enter file to write the contract to';
}
return true;
},
});
return response.trim();
};
export const namespacePrompt = async () => {
const response = await input({
message: 'Enter the namespace for the contract (optional):',
});
if (response.trim().length === 0) {
return '';
}
return response.trim();
};
export const chainPrompt = async () => {
const response = await input({
message: 'Enter the chain ID (optional):',
validate: (input) => {
const parsed = parseInt(input, 10);
if (isNaN(parsed)) {
return 'Please enter a valid number';
}
return true;
},
});
return parseInt(response, 10);
};
export const networkPrompt = async () => {
return await input({
message: 'Enter the network ID (optional):',
});
};
export const parseTreePathPrompt = async () => {
const response = await input({
message: 'Enter the path to store the parsed tree (optional):',
});
if (response.trim().length === 0) {
return '';
}
return response.trim();
};
//# sourceMappingURL=pactjs.js.map