-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
fix: help command #593
fix: help command #593
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should create a new folder called hooks, instead of adding this in the errors folder
package.json
Outdated
@@ -105,10 +104,13 @@ | |||
"main": "lib/index.js", | |||
"oclif": { | |||
"commands": "./lib/commands", | |||
"hooks": { | |||
"command_not_found": [ | |||
"./lib/hooks/command_not_found/example" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"./lib/hooks/command_not_found/example" | |
"./lib/src/errors/command-not-found" |
I think this should be the path of the hook, not really sure, looking at this example it looks like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Souvikns i've added the hook in hooks/command-not-found
folder, it should work right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that should be a file path, check that after building the project does that path has any file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's just file paths that we have to link back in package.json
. It's working build.
I just separated the hooks into folders based on events for further clarification if anyone wants to add new hooks.
@Souvikns Just a quick question before i bail out, how are we supposed to prevent the |
The plugin we are using right now is actually a hook, you can use that as an example https://github.com/oclif/plugin-not-found |
But we would still need the We basically need this new hook on top of oclif/plugin-not-found as far as i get it. please correct me. |
|
yes I read the blog and the hook was setup inside the plugin |
I don't think we need the old plugin we are replacing it with our custom hook |
This is the output @Souvikns
I just logged the options passed for reference. You can build on top of this. |
@kaushik-rishi I think we should not console.log this whole message and just console |
That output is comping from logging the opts right, now you just have to have a custom warning about it. I think if you see that log that means that the hook is connected to the CLI |
@sambhavgupta0705 yes, i just logged it for your reference. |
@sambhavgupta0705 please remove the errors folder. just reminding. |
Signed-off-by: Sambhav Gupta <[email protected]>
okay the one made by me |
@Souvikns the PR is ready for review |
package-lock.json shouldn't technically change. As we didn't install or uninstall any package I think we can safely revert package-lock.json changes. |
@Souvikns need your suggestions 🙂 i understand, but what about the fallback for other commands, the hook developed here is handling just the Also, @sambhavgupta0705 can we rather find a way to just bail out and exit after the console.log in the hook, not to forward the entire case to |
Yes we can add .exit functionality here. |
@sambhavgupta0705 for your reference. Try it once, you might see other issues. Just a hint forward. 🙂 let @Souvikns confirm if this is what we are looking forward to do. |
if (opts.id === 'help') { | ||
console.log('help command doesn\'t exist try --help'); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.exit()
is what we would want here (incase we want to exit out)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I will implement it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work, I mean if the control ever goes to the plugin it will say to use asyncapi help
command and that does not exist.
@kaushik-rishi I tried adding |
It is probably due to asynchronous nauigure, i'm afraid i don't have a solution for this right away. I can explain the situation better. |
Yess |
I have a couple of ideas, Let @Souvikns catch up and review the discussion uptill now. 🙂 We can easily make our own hook for handling every command that isn't found. Let's carry it further. |
Yeah, the plugin used to suggest or at least try to suggest an alternative command if one is wrong, I think we can build this feature, you can take inspiration from the plugin if you want. |
@Souvikns |
package-lock.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sambhavgupta0705
please revert the package-lock.json
changes.
You write the code, and you can take inspiration from it, and write it in your own way, I don't know about the license, @derberg are we breaking any rules here? |
If we have the ability to re-use the code, we can skip rewriting it 🙂 . Let @derberg clarify. We can write our own handler in the worst case, Won't be that difficult. |
@sambhavgupta0705 @kaushik-rishi, @derberg is not available right now, you can go ahead and start building the suggestion feature, no need to reuse but if you want you can take inspiration from the existing library. |
Sure @Souvikns |
Yup just busy with some work,will start working on this by this week. |
hey @kaushik-rishi ,what other changes do we need to do? |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Hey @sambhavgupta0705 |
|
@sambhavgupta0705 let us know if anything is blocking you or if you need any help. |
@Souvikns just got busy with mentorship program work .I will soon find a way to resolve this ASAP |
@sambhavgupta0705 any updates on this? |
ohh sorry I totally forgot about this |
@sambhavgupta0705 can you resolve the conflict |
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 4 New issues |
closing as looks like not needed |
Description
Related issue(s)
#559