Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: output-type markdown #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

christiangda
Copy link

@christiangda christiangda commented Feb 4, 2025

  • Extend the output format to a markdown table, allowing to show results in the Github action's workflow summary

--> --output-type= output type [values: default,markdown,cloc-xml,sloccount,json] (default: default)

I started to use this go program recently on my Github Action Workflows, and I did a bash hack to convert the --output-type=default output to Markdown table

My hack is:

      - name: Lines of code
        run: |
          echo "## Line of code" >> $GITHUB_STEP_SUMMARY

          go install github.com/hhatto/gocloc/cmd/gocloc@latest
          gocloc --not-match-d=vendor,bin,build,dist,docs,examples,scripts,testdata,tests,tools . \
          | tail -n +2 | sed -e '$ d' | sed 's/^/|/' | sed 's/ \{1,\}/  \|  /g' | sed 's/$/\|/' | tac |sed '2d'| tac | sed 's/---\{5,20\}/--|--/g' \
          | tee -a $GITHUB_STEP_SUMMARY

To show it as:

Screenshot 2025-02-04 at 14 46 20

As a hack, this is fine, but the columns were not aligned as expected, so I decided to make this pull request to do that natively in the code, so now this is the result:

Screenshot 2025-02-04 at 14 47 44

I hope this will be util and accepted

Extend the output format to markdown table allowing to shows results in github action workflows summary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant