poshbotio / PoshBot

Powershell-based bot framework
MIT License
540 stars 108 forks source link

Adjust help filter to match exact first #46

Closed RamblingCookieMonster closed 7 years ago

RamblingCookieMonster commented 7 years ago

When calling Get-CommandHelp, we check full command name, command, and aliases. A user would likely expect to run help against a command that runs, regardless of whether it is an alias or command name.

Intentionally used like. Still lets us match on unique command if user throws in a wildcard that happens to only bring back one command

Description

Details in #43

Related Issue

43

Motivation and Context

To improve poshbot-based help

How Has This Been Tested?

Manually tested.

help group

Matches group command only, with details - yay! (fixes #43)

help group*

Matches and command with group anywhere in it (previous behavior). Poshbot sees that more than one command comes back from group* command, appends * to start and end of filter. I'm iffy on this behavior now that I spell it out. Should we use -eq instead of -like?

help grou

Matches any command with grou anywhere in it (previous behavior).

Screenshots (if appropriate):

Types of changes

Depends what you classify previous behavior as : )

Checklist:

Cheers!

devblackops commented 7 years ago

This looks good to me @RamblingCookieMonster. I ran some tests with !help and the behavior is as expected. Thanks!

Can you expand a little more on this?

I'm iffy on this behavior now that I spell it out. Should we use -eq instead of -like?

RamblingCookieMonster commented 7 years ago

Just that it feels odd that if I specify *group, or get*, my query will be modified to *group* and *get*, respectively.... but if we add different handling for cases where a user includes an asterisk, code will get ugly, I think?

I'm happy with it as is though, it's consistent with existing behavior