Skip to content

Commit 33a8ea3

Browse files
authored
Enhance help message and README (#5)
* feat: Add `bold_echo` function and enhance help message * test: Update help message tests * docs: Update README and Image path
1 parent f2de064 commit 33a8ea3

File tree

4 files changed

+44
-34
lines changed

4 files changed

+44
-34
lines changed

README.md

+22-4
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,42 @@
44

55
Clean up your outdated GitHub Actions workflow logs.
66

7-
![OG Image](./img/og.png)
7+
![Cover Image](./img/cover.png)
88

99
## Usage
1010

1111
```console
1212
$ gh workflow-log-cleaner "Your Workflow Name (<workflow-id> or <workflow-name> or <filename>)"
1313
```
1414

15+
## Example
16+
17+
```console
18+
$ gh workflow-log-cleaner test
19+
```
20+
21+
```console
22+
$ gh workflow-log-cleaner test --limit 10
23+
```
24+
1525
## Don't know your workflow name?
1626

1727
If you don't know your workflow name or workflow id, you can find it by running `gh workflow-log-cleaner` without any arguments.
1828

1929
```console
2030
$ gh workflow-log-cleaner
21-
Usage:
22-
gh workflow-log-cleaner [<workflow-id> | <workflow-name> | <filename>]
31+
USAGE
32+
gh workflow-log-cleaner [<workflow-id> | <workflow-name> | <filename>] [options]
33+
34+
OPTIONS
35+
-h, --help Show this help message and exit
36+
--limit int Limit the number of runs to delete (default: 1000)
37+
38+
EXAMPLES
39+
Remove logs for the test workflow
40+
$ gh workflow-log-cleaner test
2341

24-
Available workflows:
42+
AVAILABLE WORKFLOWS
2543
NAME STATE ID
2644
setup active 114854128
2745
test active 114855097

gh-workflow-log-cleaner

+16-8
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,23 @@ export GH_PAGER=
77
LIMIT="1000"
88
WORKFLOW=""
99

10+
bold_echo() {
11+
echo -e "\e[1m$1\e[0m"
12+
}
13+
1014
help() {
11-
echo "Usage:"
15+
bold_echo "USAGE"
1216
echo "gh workflow-log-cleaner [<workflow-id> | <workflow-name> | <filename>] [options]"
1317
echo ""
14-
echo "Options:"
15-
echo " -h, --help Show this help message and exit"
16-
echo " --limit Limit the number of runs to delete (default: 1000)"
18+
bold_echo "OPTIONS"
19+
echo " -h, --help Show this help message and exit"
20+
echo " --limit int Limit the number of runs to delete (default: 1000)"
1721
echo ""
18-
echo "Available workflows:"
22+
bold_echo "EXAMPLES"
23+
echo " Remove logs for the test workflow"
24+
echo " $ gh workflow-log-cleaner test"
25+
echo ""
26+
bold_echo "AVAILABLE WORKFLOWS"
1927
gh workflow list --all
2028
}
2129

@@ -47,9 +55,9 @@ while [ $# -gt 0 ]; do
4755
done
4856

4957
if [ -z "$WORKFLOW" ]; then
50-
echo "Error: Specify a workflow to delete the log."
51-
help
52-
exit 1
58+
echo "Error: Specify a workflow to delete the log."
59+
help
60+
exit 1
5361
fi
5462

5563
for id in $(gh run list --workflow "$WORKFLOW" --json databaseId --jq '.[].databaseId' --limit $LIMIT); do

gh-workflow-log-cleaner.bats

+6-22
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,17 @@ assert_output_contains() {
1010
@test "without parameter" {
1111
run ./gh-workflow-log-cleaner
1212
[ "$status" -eq 0 ]
13-
expected_output="Usage:
14-
gh workflow-log-cleaner [<workflow-id> | <workflow-name> | <filename>] [options]
15-
16-
Options:
17-
-h, --help Show this help message and exit
18-
--limit Limit the number of runs to delete (default: 1000)
19-
20-
Available workflows:
21-
setup active 114854128
22-
test active 114855097"
23-
[ "$output" = "$expected_output" ]
13+
assert_output_contains 'gh workflow-log-cleaner [<workflow-id> | <workflow-name> | <filename>] [options]'
14+
assert_output_contains 'setup active 114854128
15+
test active 114855097'
2416
}
2517

2618
@test "with help option" {
2719
run ./gh-workflow-log-cleaner --help
2820
[ "$status" -eq 0 ]
29-
expected_output="Usage:
30-
gh workflow-log-cleaner [<workflow-id> | <workflow-name> | <filename>] [options]
31-
32-
Options:
33-
-h, --help Show this help message and exit
34-
--limit Limit the number of runs to delete (default: 1000)
35-
36-
Available workflows:
37-
setup active 114854128
38-
test active 114855097"
39-
[ "$output" = "$expected_output" ]
21+
assert_output_contains 'gh workflow-log-cleaner [<workflow-id> | <workflow-name> | <filename>] [options]'
22+
assert_output_contains 'setup active 114854128
23+
test active 114855097'
4024
}
4125

4226
@test "with a workflow-name and limit option" {
File renamed without changes.

0 commit comments

Comments
 (0)