Skip to content

Commit

Permalink
Add progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
lhsazevedo committed Jul 19, 2024
1 parent ddda814 commit 56fd391
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
[![Build](https://github.com/lhsazevedo/tokyo-bus-guide-decomp/actions/workflows/build.yml/badge.svg)](https://github.com/lhsazevedo/tokyo-bus-guide-decomp/actions/workflows/build.yml)
[![Build Matching](https://github.com/lhsazevedo/tokyo-bus-guide-decomp/actions/workflows/build_matching.yml/badge.svg)](https://github.com/lhsazevedo/tokyo-bus-guide-decomp/actions/workflows/build_matching.yml)

## Decompilation progress: 12.64%
#### Decompilation progress: 12.64%
![Progress Bar](https://progress-bar.dev/12/?width=300)

![Main function hero](./tbg.png)

Expand Down
29 changes: 20 additions & 9 deletions scripts/progress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ remaining_lines=$(grep -lE "SECTION\s+P" src/asm/*.src | xargs cat | grep -vE ".
decompiled_total=$((matched_lines + decompiled_lines))
total_lines=$((decompiled_total + remaining_lines))

if [ $total_lines -ne 0 ]; then
progress_percentage=$(echo "scale=4; $decompiled_total / $total_lines * 100" | bc)
progress_percentage=$(printf "%.2f" $progress_percentage)
else
progress_percentage=0
if [ $total_lines -eq 0 ]; then
echo "Total lines is 0!"
exit
fi

progress_percentage=$(echo "scale=4; $decompiled_total / $total_lines * 100" | bc)
progress_percentage=$(printf "%.2f" $progress_percentage)
progress_percentage_int=${progress_percentage%.*}

echo "Matched lines: $matched_lines"
echo "Decompiled lines: $decompiled_lines"
echo "Decompiled total: $decompiled_total"
Expand All @@ -25,9 +27,18 @@ echo "Progress percentage: $progress_percentage%"
# Update README file with progress
readme_file="README.md"

if grep -q "Decompilation Progress:" "$readme_file"; then
sed -i "s/Decompilation Progress: [0-9.]\+%/Decompilation progress: $progress_percentage%/" "$readme_file"
echo "README file updated with current progress."
else
if ! grep -q "Decompilation Progress:" "$readme_file"; then
echo "Progress not found in README file!"
exit 1
fi

sed -i "s/Decompilation Progress: [0-9.]\+%/Decompilation progress: $progress_percentage%/" "$readme_file"
echo "README file updated with current progress."

if ! grep -q "https://progress-bar.dev/" "$readme_file"; then
echo "Progress bar not found in README file!"
exit 1
fi

sed -i "s/https:\/\/progress-bar.dev\/[0-9]\+/https:\/\/progress-bar.dev\/$progress_percentage_int/" "$readme_file"
echo "README progress bar updated."

0 comments on commit 56fd391

Please sign in to comment.