feat(cli.ts, commit.ts): add --yes flag to skip commit confirmation prompt (#341)
docs(README.md): document the `--yes` flag usage in README for user guidance
This commit is contained in:
@@ -84,6 +84,14 @@ This is due to limit the number of tokens sent in each request. However, if you
|
|||||||
oco --fgm
|
oco --fgm
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Skip Commit Confirmation
|
||||||
|
|
||||||
|
This flag allows users to automatically commit the changes without having to manually confirm the commit message. This is useful for users who want to streamline the commit process and avoid additional steps. To use this flag, you can run the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
oco --yes
|
||||||
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
### Local per repo configuration
|
### Local per repo configuration
|
||||||
|
|||||||
+8
-2
@@ -18,7 +18,13 @@ cli(
|
|||||||
name: 'opencommit',
|
name: 'opencommit',
|
||||||
commands: [configCommand, hookCommand, commitlintConfigCommand],
|
commands: [configCommand, hookCommand, commitlintConfigCommand],
|
||||||
flags: {
|
flags: {
|
||||||
fgm: Boolean
|
fgm: Boolean,
|
||||||
|
yes: {
|
||||||
|
type: Boolean,
|
||||||
|
alias: 'y',
|
||||||
|
description: 'Skip commit confirmation prompt',
|
||||||
|
default: false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
ignoreArgv: (type) => type === 'unknown-flag' || type === 'argument',
|
ignoreArgv: (type) => type === 'unknown-flag' || type === 'argument',
|
||||||
help: { description: packageJSON.description }
|
help: { description: packageJSON.description }
|
||||||
@@ -29,7 +35,7 @@ cli(
|
|||||||
if (await isHookCalled()) {
|
if (await isHookCalled()) {
|
||||||
prepareCommitMessageHook();
|
prepareCommitMessageHook();
|
||||||
} else {
|
} else {
|
||||||
commit(extraArgs, false, flags.fgm);
|
commit(extraArgs, false, flags.fgm, flags.yes);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
extraArgs
|
extraArgs
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ const checkMessageTemplate = (extraArgs: string[]): string | false => {
|
|||||||
const generateCommitMessageFromGitDiff = async (
|
const generateCommitMessageFromGitDiff = async (
|
||||||
diff: string,
|
diff: string,
|
||||||
extraArgs: string[],
|
extraArgs: string[],
|
||||||
fullGitMojiSpec: boolean
|
fullGitMojiSpec: boolean,
|
||||||
|
skipCommitConfirmation: boolean
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
await assertGitRepo();
|
await assertGitRepo();
|
||||||
const commitSpinner = spinner();
|
const commitSpinner = spinner();
|
||||||
@@ -76,7 +77,7 @@ ${commitMessage}
|
|||||||
${chalk.grey('——————————————————')}`
|
${chalk.grey('——————————————————')}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const isCommitConfirmedByUser = await confirm({
|
const isCommitConfirmedByUser = skipCommitConfirmation || await confirm({
|
||||||
message: 'Confirm the commit message?'
|
message: 'Confirm the commit message?'
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -178,7 +179,8 @@ ${chalk.grey('——————————————————')}`
|
|||||||
export async function commit(
|
export async function commit(
|
||||||
extraArgs: string[] = [],
|
extraArgs: string[] = [],
|
||||||
isStageAllFlag: Boolean = false,
|
isStageAllFlag: Boolean = false,
|
||||||
fullGitMojiSpec: boolean = false
|
fullGitMojiSpec: boolean = false,
|
||||||
|
skipCommitConfirmation: boolean = false
|
||||||
) {
|
) {
|
||||||
if (isStageAllFlag) {
|
if (isStageAllFlag) {
|
||||||
const changedFiles = await getChangedFiles();
|
const changedFiles = await getChangedFiles();
|
||||||
@@ -250,7 +252,8 @@ export async function commit(
|
|||||||
generateCommitMessageFromGitDiff(
|
generateCommitMessageFromGitDiff(
|
||||||
await getDiff({ files: stagedFiles }),
|
await getDiff({ files: stagedFiles }),
|
||||||
extraArgs,
|
extraArgs,
|
||||||
fullGitMojiSpec
|
fullGitMojiSpec,
|
||||||
|
skipCommitConfirmation
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user