mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 16:30:57 +00:00
fix(tooling): add committer help output
This commit is contained in:
@@ -4,10 +4,19 @@ set -euo pipefail
|
||||
# Disable glob expansion to handle brackets in file paths
|
||||
set -f
|
||||
usage() {
|
||||
printf 'Usage: %s [--force] [--fast] "commit message" "file" ["file" ...]\n' "$(basename "$0")" >&2
|
||||
exit 2
|
||||
local exit_code=${1:-2}
|
||||
if [ "$exit_code" -eq 0 ]; then
|
||||
printf 'Usage: %s [--force] [--fast] "commit message" "file" ["file" ...]\n' "$(basename "$0")"
|
||||
else
|
||||
printf 'Usage: %s [--force] [--fast] "commit message" "file" ["file" ...]\n' "$(basename "$0")" >&2
|
||||
fi
|
||||
exit "$exit_code"
|
||||
}
|
||||
|
||||
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
|
||||
usage 0
|
||||
fi
|
||||
|
||||
if [ "$#" -lt 2 ]; then
|
||||
usage
|
||||
fi
|
||||
@@ -24,6 +33,9 @@ while [[ "${1:-}" == --* ]]; do
|
||||
fast_commit=true
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
usage 0
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
|
||||
@@ -160,4 +160,14 @@ describe("scripts/committer", () => {
|
||||
expect(output).toContain('Committed "test: fast hook env" with 1 files');
|
||||
expect(committedPaths(repo)).toEqual(["note.txt"]);
|
||||
});
|
||||
|
||||
it("prints usage for --help", () => {
|
||||
const repo = createRepo();
|
||||
|
||||
const output = commitWithHelperArgs(repo, "--help");
|
||||
|
||||
expect(output).toContain(
|
||||
'Usage: committer [--force] [--fast] "commit message" "file" ["file" ...]',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user