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

vlib: rewrite vlib/v/help, fix print_help_and_exit for sub topics #19672

Merged
merged 2 commits into from
Oct 28, 2023

Conversation

ttytm
Copy link
Member

@ttytm ttytm commented Oct 26, 2023

Currently, when running v fmt --help it prints:

`v help`: unknown help topic provided. Use `v help` for usage information.
Known help topics: .

This is despite vfmt accepting a help flag and calling the print_help function:

v/cmd/tools/vfmt.v

Lines 90 to 91 in f705897

if files.len == 0 || '-help' in args || '--help' in args {
help.print_and_exit('fmt')

This PR fixes it and extends the modules test coverage and better error information.
It is a small module so it was rewritten to improve the module's suboptimalities.

As a note when testing the changes locally: it's required to re-run v self to include when checking out the branch.

🤖 Generated by Copilot at 7a7a403

This pull request refactors and improves the help and help_test modules in the V standard library. It uses new compiler attributes to get the paths to the V executable and the help topics, simplifies the code logic and structure, and adds more test cases.

🤖 Generated by Copilot at 7a7a403

  • Refactor the print_and_exit function to use the new attributes and helper functions (link)
  • Update the help_test module to use the new attributes and the os.quoted_path function (link, link)
  • Rename the test_all_help function to test_all_topics and add two new test functions (link)
  • Simplify the logic of getting the topic names from the file paths in test_all_topics (link)

@ttytm ttytm force-pushed the vlib/rewrite-help branch 4 times, most recently from 0597cba to 5a28720 Compare October 27, 2023 15:12
@ttytm ttytm force-pushed the vlib/rewrite-help branch from 5a28720 to 314932c Compare October 27, 2023 15:15
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work!

The new code is simpler, more robust, and better tested.

@spytheman spytheman merged commit 573188a into vlang:master Oct 28, 2023
@ttytm ttytm deleted the vlib/rewrite-help branch October 28, 2023 19:39
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.

2 participants