@@ -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.
@@ -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
</formatted-commit_flags>
<formatted-commit_example>
@@ -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
@@ -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)