feat: --all flag (#182)
Co-authored-by: Hiroki Osame <hiroki.osame@gmail.com>
This commit is contained in:
@@ -29,6 +29,12 @@ cli(
|
||||
description: 'Files to exclude from AI analysis',
|
||||
alias: 'x',
|
||||
},
|
||||
all: {
|
||||
type: Boolean,
|
||||
description: 'Automatically stage changes in tracked files for the commit',
|
||||
alias: 'a',
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
|
||||
commands: [
|
||||
@@ -49,6 +55,7 @@ cli(
|
||||
aicommits(
|
||||
argv.flags.generate,
|
||||
argv.flags.exclude,
|
||||
argv.flags.all,
|
||||
rawArgv,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,18 +17,24 @@ import { KnownError, handleCliError } from '../utils/error.js';
|
||||
export default async (
|
||||
generate: number | undefined,
|
||||
excludeFiles: string[],
|
||||
stageAll: boolean,
|
||||
rawArgv: string[],
|
||||
) => (async () => {
|
||||
intro(bgCyan(black(' aicommits ')));
|
||||
await assertGitRepo();
|
||||
|
||||
const detectingFiles = spinner();
|
||||
|
||||
if (stageAll) {
|
||||
await execa('git', ['add', '--all']);
|
||||
}
|
||||
|
||||
detectingFiles.start('Detecting staged files');
|
||||
const staged = await getStagedDiff(excludeFiles);
|
||||
|
||||
if (!staged) {
|
||||
detectingFiles.stop('Detecting staged files');
|
||||
throw new KnownError('No staged changes found. Make sure to stage your changes with `git add`.');
|
||||
throw new KnownError('No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.');
|
||||
}
|
||||
|
||||
detectingFiles.stop(`${getDetectedMessage(staged.files)}:\n${
|
||||
|
||||
Reference in New Issue
Block a user