feat: --all flag (#182)

Co-authored-by: Hiroki Osame <hiroki.osame@gmail.com>
This commit is contained in:
Rocktim
2023-04-01 15:49:34 +05:30
committed by GitHub
parent ad2533eb2f
commit ebe83a493e
5 changed files with 55 additions and 5 deletions

View File

@@ -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,
);
}

View File

@@ -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${