cli
cli copied to clipboard
fix: help command
Description
- ...
- ...
- ...
Related issue(s)
#559
@Souvikns Just a quick question before i bail out, how are we supposed to prevent the
@oclif/plugin-not-found from triggering, inside the hook that we are working with ?
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
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 oclif/plugin-not-found for any other user entered commands which donot exist right ?
We basically need this new hook on top of oclif/plugin-not-found as far as i get it. please correct me.
This is the output @Souvikns
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
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
https://github.com/asyncapi/cli/blob/479c31d8c4652831b0c6472ba49a77e8cf7b189d/src/hooks/command_not_found/help-command-handler.ts#L4
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 help command doesn't exist try --help
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. i've written an if condition below it inside of which you can build.
@sambhavgupta0705 please remove the errors folder. just reminding.
@sambhavgupta0705 please remove the errors folder. just reminding.
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.
I don't think we need the old plugin we are replacing it with our custom hook
@Souvikns need your suggestions 🙂
i understand, but what about the fallback for other commands, the hook developed here is handling just the help command and suggesting the user to use --help.
What if i use something like asyncapi generte (intentional typo), we would still need the plugin-not-found to give us a fallback option to suggestions from the plugin right ?
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 plugin-not-found module ?
Yes we can add .exit functionality here.
@sambhavgupta0705 for your reference.
follow the last line of this documentation https://oclif.io/docs/hooks.
you can use this.exit() to exit out instead of going further.
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.
@kaushik-rishi I tried adding this.exit() but the plugin console was always get printed
@kaushik-rishi I tried adding
this.exit()but the plugin console was always get printed
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.
May be it's like once the hook is triggered both the plugins (the one we wrote and the plugin-not-found) and being called at the same time. It is exiting fine but before exiting it's printing the first line of the plugin-not-founds prompt.
Yess
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.
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 I'm not very aware of the licenes, but looking at this (licence), are we allowed to copy the code into our hook and then modify as per our requirements ?
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?
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 :slightly_smiling_face: . 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
@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.
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
0 Vulnerabilities
0 Security Hotspots
0 Code Smells
No Coverage information
1.0% Duplication
