diff --git a/AGENTS.md b/AGENTS.md index 0e507e2c9d8caae3e6ca603d7df97311e869d9a3..e5ff25e8a7ff4233ed40c80c73fcc988eab81f7b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -109,10 +109,11 @@ Assisted-by: This is a very long value, with spaces and - `-B` / `--breaking`: Boolean flag for breaking changes (adds `!` to subject) - `-b` / `--body`: String flag for commit body text (can use heredoc for multiline) - `-T` / `--trailer`: Repeatable flag accepting full trailer strings in `Key: value` format (not separate key/value args) -- `-a` / `--amend`: Boolean flag to amend the previous commit instead of creating a new one +- `-a` / `--add`: Boolean flag to stage all modified files before committing (optional) +- `--amend`: Boolean flag to amend the previous commit instead of creating a new one (optional) Trailer format detail: Each `-T` flag takes a complete trailer string like `-T "Assisted-by: GLM 4.6 via Crush"`, NOT separate key and value arguments. ### Final Output -The formatted commit message must be piped to `git commit -F -` to read from stdin. When the `-a`/`--amend` flag is used, it pipes to `git commit --amend -F -` instead. +The formatted commit message must be piped to `git commit -F -` to read from stdin. When the `--amend` flag is used, it pipes to `git commit --amend -F -` instead. diff --git a/README.md b/README.md index 00b7d9b2a1ba76abbb82ec762acb324e977031a3..b45aeb7a837cb87667401bc3dde836f69aedeed0 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,8 @@ Create/amend commits exclusively using `formatted-commit`. Try to use it normall -m --message Commit message (required) -b --body Commit body (optional) -T --trailer Trailer in 'Sentence-case-key: value' format (optional, repeatable) --a --amend Amend the previous commit (optional) +-a --add Stage all modified files before committing (optional) +--amend Amend the previous commit (optional) -h --help @@ -154,7 +155,8 @@ $ formatted-commit -h FLAGS - -a --amend Amend the previous commit (optional) + -a --add Stage all modified files before committing (optional) + --amend Amend the previous commit (optional) -b --body Commit body (optional) -B --breaking Mark as breaking change (optional) -h --help Help for formatted-commit diff --git a/main.go b/main.go index cf34bcdbd815aef8673554272666a54afec596b8..8e4b62f3dbb3daddfdeac1200c70f789483f9e39 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ var ( body string scope string breakingChange bool + add bool amend bool ) @@ -84,6 +85,9 @@ formatted-commit upgrade -a } gitArgs := []string{"commit"} + if add { + gitArgs = append(gitArgs, "-a") + } if amend { gitArgs = append(gitArgs, "--amend") } @@ -124,7 +128,8 @@ func init() { rootCmd.Flags().StringVarP(&body, "body", "b", "", "commit body (optional)") rootCmd.Flags().StringVarP(&scope, "scope", "s", "", "commit scope (optional)") rootCmd.Flags().BoolVarP(&breakingChange, "breaking", "B", false, "mark as breaking change (optional)") - rootCmd.Flags().BoolVarP(&amend, "amend", "a", false, "amend the previous commit (optional)") + rootCmd.Flags().BoolVarP(&add, "add", "a", false, "stage all modified files before committing (optional)") + rootCmd.Flags().BoolVar(&amend, "amend", false, "amend the previous commit (optional)") if err := rootCmd.MarkFlagRequired("type"); err != nil { panic(err)