Skip to content

config --set: Add case-insensitive matching and fuzzy suggestions#241

Open
stakeswky wants to merge 1 commit intonbfc-linux:mainfrom
stakeswky:fix-config-set-fuzzy-suggestions
Open

config --set: Add case-insensitive matching and fuzzy suggestions#241
stakeswky wants to merge 1 commit intonbfc-linux:mainfrom
stakeswky:fix-config-set-fuzzy-suggestions

Conversation

@stakeswky
Copy link
Copy Markdown

Fixes #239

When nbfc config --set MODEL fails to find an exact config match, this PR improves the experience:

  1. Case-insensitive matching: nbfc config --set 'lenovo thinkpad l540' now resolves to Lenovo Thinkpad L540 without error.

  2. Fuzzy suggestions: If no case-insensitive match is found, the command now shows "Did you mean?" suggestions using Levenshtein similarity and substring matching. This directly addresses the confusion where the NotebookModel field inside a JSON config (e.g. Thinkpad L540) differs from the config filename (Lenovo Thinkpad L540):

    $ sudo nbfc config --set 'Thinkpad L540'
    Error: No such configuration available: Thinkpad L540
    
    Did you mean one of these?
      Lenovo Thinkpad L540
    
  3. Fallback hint: If no suggestions are found, the user is pointed to nbfc config -l.

Note: nbfc config --list already exists and was mentioned in the issue — the help text already documents it.

When 'nbfc config --set MODEL' fails to find an exact match:

1. Try case-insensitive matching first (e.g. 'lenovo thinkpad l540'
   now resolves to 'Lenovo Thinkpad L540')

2. If no case-insensitive match, show 'Did you mean?' suggestions
   using Levenshtein similarity and substring matching. This helps
   when users type the NotebookModel field value (e.g. 'Thinkpad L540')
   instead of the config filename ('Lenovo Thinkpad L540').

3. If no suggestions found, point users to 'nbfc config -l'.

Closes nbfc-linux#239
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.

[Bug]: sudo nbfc config --set "<MODEL>" should be sudo nbfc config --set "MODEL"

1 participant