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

add help options to display helper text for cmd applications #661

Merged
merged 26 commits into from
Jun 10, 2024

Conversation

IvanGael
Copy link
Contributor

@IvanGael IvanGael commented May 28, 2024

Closes: #568

Description:

There are the changes have been made

// cmd.go

  • Structure for Sub-Commands:route struct now includes a description field to store the command description.
  • Handling -h or --help:he Run method checks for -h or --help flags. If found, it calls cmd.printHelp() to print the help message and exits.
  • Listing Sub-Commands: printHelp method prints all registered sub-commands along with their descriptions.
  • Default Command Handling: If no command is provided or an unknown command is encountered, the help message is printed along with an error message.

The files cmd_test.go, gofr.go, gofr_test.go and examples/sample-cmd/main.go are updated accordingly.

Checklist:

  • I have formatted my code using goimport and golangci-lint.
  • All new code is covered by unit tests.
  • This PR does not decrease the overall code coverage.
  • I have reviewed the code comments and documentation for clarity.

Copy link
Contributor

@ccoVeille ccoVeille left a comment

Choose a reason for hiding this comment

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

My feedback on your changes, you can of course ignore them

pkg/gofr/cmd.go Outdated Show resolved Hide resolved
pkg/gofr/gofr_test.go Show resolved Hide resolved
pkg/gofr/gofr.go Outdated Show resolved Hide resolved
@vipul-rawat
Copy link
Member

@IvanGael This gives user to define the custom helper doc to be used printed for each sub command. We also wanted to have a default helper functionality that prints all available sub commands for the executed command in case the command is not present.

@IvanGael
Copy link
Contributor Author

@vipul-rawat After fixing the issues and implementing the various suggestions, should I close this pull request before creating another one?

@vipul-rawat
Copy link
Member

vipul-rawat commented May 28, 2024

@vipul-rawat After fixing the issues and implementing the various suggestions, should I close this pull request before creating another one?

@IvanGael Try to update this PR itself

Also please fix the merge conflicts

@IvanGael
Copy link
Contributor Author

@vipul-rawat I just added new commit to this PR. Try to review.

@IvanGael
Copy link
Contributor Author

@vipul-rawat What causes merge conflict issues?

Copy link
Contributor

@ccoVeille ccoVeille left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. I way simpler to read and maintain now, I think.

I will let maintainers/owner share their point of view

pkg/gofr/cmd_test.go Outdated Show resolved Hide resolved
pkg/gofr/cmd_test.go Outdated Show resolved Hide resolved
@srijan-27
Copy link
Contributor

srijan-27 commented May 28, 2024

@vipul-rawat What causes merge conflict issues?

@IvanGael - Merge conflicts happen when 2 branches make different changes to the single line, it would be because of other PR (which had changes to the same line as this branch) getting merged to base branch. You can resolve them easily, but be careful as we would not want to remove the changes from other branch.

@vipul-rawat vipul-rawat changed the title issue #568 attempt1 solved! add help options to display helper text for cmd applications May 28, 2024
@IvanGael
Copy link
Contributor Author

Okay @srijan-27 I will try to resolve it

@IvanGael
Copy link
Contributor Author

@vipul-rawat @srijan-27 @ccoVeille I don't understant why this line cause conflict

Screenshot 2024-05-30 123705

@ccoVeille
Copy link
Contributor

In such a case there is no real need to understand. Remove everything between <<<< and >>>> then save. Your IDE will fix the import

@vipul-rawat
Copy link
Member

@IvanGael are you still having trouble fixing the conflict?

@IvanGael
Copy link
Contributor Author

@vipul-rawat Normally there should be no more merge conflicts because I did what @ccoVeille suggested to me. I don't understand why this issue persists. Could you help me with this ?

@vipul-rawat
Copy link
Member

@vipul-rawat Normally there should be no more merge conflicts because I did what @ccoVeille suggested to me. I don't understand why this issue persists. Could you help me with this ?

You need to update your branch in the forked repo with the current development branch of this repo(in which this PR merges the code).
To do this:

  • Add a remote repo with this repo's link - git remote add gofr https://github.com/gofr-dev/gofr
  • Merge the development onto your branch- git pull gofr development

These 2 steps should give you a conflict in your gofr_test file, resolve them and push it to your branch.

@IvanGael
Copy link
Contributor Author

@vipul-rawat Check if all is good for the merging

pkg/gofr/gofr.go Outdated Show resolved Hide resolved
pkg/gofr/cmd.go Outdated Show resolved Hide resolved
@IvanGael
Copy link
Contributor Author

IvanGael commented Jun 1, 2024

Screenshot 2024-06-01 022509

pkg/gofr/cmd.go Outdated Show resolved Hide resolved
pkg/gofr/cmd.go Outdated Show resolved Hide resolved
@IvanGael IvanGael requested a review from vipul-rawat June 4, 2024 11:16
pkg/gofr/gofr.go Outdated Show resolved Hide resolved
@vipul-rawat
Copy link
Member

@IvanGael tests and code quality checks are failing, please use golang ci-lint v1.57.2 to check for any linter.

Copy link
Contributor

@aryanmehrotra aryanmehrotra left a comment

Choose a reason for hiding this comment

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

  1. Response doesn't seem right with unwanted square brackets
image

Would be better if we have something similar to how other help commands look like of -git or github (gh)
No Command Found! is also misleading because help is the command

pkg/gofr/cmd.go Outdated Show resolved Hide resolved
pkg/gofr/cmd.go Outdated Show resolved Hide resolved
pkg/gofr/gofr.go Show resolved Hide resolved
pkg/gofr/gofr_test.go Outdated Show resolved Hide resolved
@IvanGael IvanGael requested a review from ccoVeille June 10, 2024 07:59
Copy link
Contributor

@ccoVeille ccoVeille left a comment

Choose a reason for hiding this comment

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

Only one small question

pkg/gofr/cmd.go Show resolved Hide resolved
Copy link
Member

@vipul-rawat vipul-rawat left a comment

Choose a reason for hiding this comment

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

Please remove the unused code - fullpattern field

Rest implementation look good 👍

pkg/gofr/cmd.go Outdated Show resolved Hide resolved
@vipul-rawat vipul-rawat dismissed their stale review June 10, 2024 10:54

Rereviewing

aryanmehrotra
aryanmehrotra previously approved these changes Jun 10, 2024
@aryanmehrotra aryanmehrotra merged commit ea9107e into gofr-dev:development Jun 10, 2024
11 checks passed
@ccoVeille
Copy link
Contributor

You did it @IvanGael

@IvanGael
Copy link
Contributor Author

@ccoVeille I'm glad you appreciate it. Looking forward to continue to contribute to this project.

@aryanmehrotra aryanmehrotra mentioned this pull request Jun 11, 2024
aryanmehrotra added a commit that referenced this pull request Jun 11, 2024
* Update workflow and docs for docs deployment (#693)

* Revert "Update workflow and docs for docs deployment (#693)" (#694)

This reverts commit c2e022d.

* Added additional logging for datasource (#655)

Co-authored-by: Umang Mundhra <[email protected]>
Co-authored-by: Srijan Rastogi <[email protected]>
Co-authored-by: srijan-27 <[email protected]>

* Fe/support for cassandra (#654)

Co-authored-by: Aryan Mehrotra <[email protected]>
Co-authored-by: Umang Mundhra <[email protected]>
Co-authored-by: mehrotra234 <[email protected]>

* Add support for local file store (#695)

* add help options to display helper text for cmd applications (#661)

---------

Co-authored-by: Aryan Mehrotra <[email protected]>
Co-authored-by: vipul-rawat <[email protected]>

* Revert request_timeout default value (#699)

* upgrade framework version

---------

Co-authored-by: Aryan Mehrotra <[email protected]>
Co-authored-by: KedarisettiSreeVamsi <[email protected]>
Co-authored-by: Umang Mundhra <[email protected]>
Co-authored-by: Shashank Shekhar <[email protected]>
Co-authored-by: mehrotra234 <[email protected]>
Co-authored-by: Ivan APEDO <[email protected]>
Co-authored-by: vipul-rawat <[email protected]>
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.

Add -h or --help for gofr.NewCMD()
6 participants