@@ -529,44 +529,21 @@ def main() -> None:
529529 output (open_file .read ().encode ('utf-8' ).splitlines (),
530530 plain = options .markdown )
531531 elif options .search :
532- command = '-' .join (options .command )
533- page = None
534- maxprob = 0
535- searchquery = options .search .split (' ' )
536-
537- platforms = get_platform_list ()
538- for i in get_commands (platforms ):
539- if i .startswith (command ):
540- for p in platforms :
541- result = load_page_from_cache (i , p , options .language )
542- if result is not None and have_recent_cache (i , p , options .language ):
543- break
544- if result is None :
545- raise SystemExit ("Please update cache" )
546- result = result .decode ("utf-8" )
547- result = result .split ()
548- for word in searchquery :
549- prob = 0
550- for line in result :
551- line = line .lower ()
552- if word in line :
553- prob += 1
554- if line .startswith ("#" ):
555- prob += 7
556- elif line .startswith (">" ):
557- prob += 5
558- elif line .startswith ("-" ):
559- prob += 2
560- if prob > maxprob :
561- maxprob = prob
562- page = i
563-
564- if page :
565- result = get_page (page , None , options .platform , options .language )
566- output (result , plain = options .markdown )
532+ search_term = options .search .lower ()
533+ commands = get_commands (options .platform , options .language )
534+ if not commands :
535+ print ("Update cache, no commands to check from." )
536+ return
537+ similar_commands = []
538+ for command in commands :
539+ if search_term in command .lower ():
540+ similar_commands .append (command )
541+ if similar_commands :
542+ print ("Similar commands found:" )
543+ print ('\n ' .join (similar_commands ))
544+ return
567545 else :
568- print ("No results found" )
569-
546+ print ("No commands matched your search term." )
570547 else :
571548 try :
572549 command = '-' .join (options .command ).lower ()
0 commit comments