Skip to content

Commit

Permalink
feat(cli-flags): add --include-empty-directories flag
Browse files Browse the repository at this point in the history
  • Loading branch information
massdo committed Jan 27, 2025
1 parent 7b0898a commit 8d359aa
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ This format provides a clean, readable structure that is both human-friendly and
- `--token-count-encoding <encoding>`: Specify token count encoding (e.g., `o200k_base`, `cl100k_base`)
- `--verbose`: Enable verbose logging
- `--instruction-file-path <path>`: Path to a file containing detailed custom instructions
- `--include-empty-directories`: Include empty directories in the output

Examples:

Expand Down
3 changes: 3 additions & 0 deletions src/cli/actions/defaultAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ const buildCliConfig = (options: CliOptions): RepomixConfigCli => {
if (options.instructionFilePath) {
cliConfig.output = { ...cliConfig.output, instructionFilePath: options.instructionFilePath };
}
if (options.includeEmptyDirectories) {
cliConfig.output = { ...cliConfig.output, includeEmptyDirectories: options.includeEmptyDirectories };
}

try {
return repomixConfigCliSchema.parse(cliConfig);
Expand Down
2 changes: 2 additions & 0 deletions src/cli/cliRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface CliOptions extends OptionValues {
removeEmptyLines?: boolean;
tokenCountEncoding?: string;
instructionFilePath?: string;
includeEmptyDirectories?: boolean;
}

export const run = async () => {
Expand Down Expand Up @@ -71,6 +72,7 @@ export const run = async () => {
)
.option('--no-security-check', 'disable security check')
.option('--instruction-file-path <path>', 'path to a file containing detailed custom instructions')
.option('--include-empty-directories', 'include empty directories in the output')
.action((directory = '.', options: CliOptions = {}) => executeAction(directory, process.cwd(), options));

await program.parseAsync(process.argv);
Expand Down
20 changes: 20 additions & 0 deletions tests/cli/actions/defaultAction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,24 @@ describe('defaultAction', () => {
);
});
});

describe('includeEmptyDirectories flag', () => {
it('should handle --include-empty-directories flag', async () => {
const options: CliOptions = {
includeEmptyDirectories: true,
};

await runDefaultAction('.', process.cwd(), options);

expect(configLoader.mergeConfigs).toHaveBeenCalledWith(
process.cwd(),
expect.anything(),
expect.objectContaining({
output: {
includeEmptyDirectories: true,
},
}),
);
});
});
});
12 changes: 12 additions & 0 deletions tests/cli/cliRun.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,5 +268,17 @@ describe('cliRun', () => {
}),
);
});

test('should handle --include-empty-directories flag', async () => {
await executeAction('.', process.cwd(), { includeEmptyDirectories: true });

expect(defaultAction.runDefaultAction).toHaveBeenCalledWith(
'.',
process.cwd(),
expect.objectContaining({
includeEmptyDirectories: true,
}),
);
});
});
});

0 comments on commit 8d359aa

Please sign in to comment.