Skip to content

Commit

Permalink
Merge pull request #1119 from polyseam/log-response-count
Browse files Browse the repository at this point in the history
feat: log the number of responses pulled during init/create
  • Loading branch information
johnstonmatt authored Jan 24, 2025
2 parents a391ce0 + 335cc81 commit 1eebfa1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
22 changes: 17 additions & 5 deletions src/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ const createCommand = new Command()
console.error(
label,
ccolors.error("Error loading"),
ccolors.key_name("cndi_responses.yaml"),
ccolors.error("file"),
ccolors.key_name(options.responsesFile),
ccolors.error("as responses file"),
);
ccolors.caught(errLoadingResponsesFile as Error, 1502);
console.log(
Expand All @@ -257,8 +257,8 @@ const createCommand = new Command()
const err = new ErrOut(
[
ccolors.error("Error parsing"),
ccolors.key_name("cndi_responses.yaml"),
ccolors.error("file"),
ccolors.key_name(options.responsesFile),
ccolors.error("as responses file"),
],
{
label,
Expand All @@ -271,7 +271,19 @@ const createCommand = new Command()
return;
}

if (responses) {
const responseCount = Object.keys(responses).length;

if (responseCount) {
console.log();
console.log(
ccolors.key_name("cndi"),
"is pulling",
ccolors.success(responseCount.toString()),
"responses from",
ccolors.success(options.responsesFile) +
"!",
);
console.log();
overrides = responses as Record<
string,
CNDITemplatePromptResponsePrimitive
Expand Down
20 changes: 18 additions & 2 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,24 @@ const initCommand = new Command()
}

try {
const responses = YAML.parse(responseFileText);
if (responses) {
const responses = YAML.parse(responseFileText) as Record<
string,
CNDITemplatePromptResponsePrimitive
>;

const responseCount = Object.keys(responses).length;

if (responseCount) {
console.log();
console.log(
ccolors.key_name("cndi"),
"is pulling",
ccolors.success(responseCount.toString()),
"responses from",
ccolors.success(options.responsesFile) +
"!",
);
console.log();
overrides = responses as Record<
string,
CNDITemplatePromptResponsePrimitive
Expand Down

0 comments on commit 1eebfa1

Please sign in to comment.