function slexOpen(str, options)
% SLEXOPEN  Find and open an example or custom model
%
%  Syntax
%   slexOpen(str)
%   slexOpen(__,Name,Value)
%
%  Description
%   slexOpen(str) finds and opens the model that matches the search term
%   str. If there is more than one match, then all matching items are
%   displayed as a list and you are prompted to select one of them. Other
%   options in the prompt include (q) to quit and (m) to see more results.
%
%   slexOpen(__,Name,Value) offers additional options to filter and
%   display search results.
%
%   Items that appear indented and prefixed with ">" are individual
%   Simulink models that are part of a bigger Example or Project. You
%   may open an individual model or an entire example, with the
%   corresponding number, depending on your search requirement.
%
%   If the search term str is longer than 3 words, slexOpen automatically
%   switches to Natural Language mode to find more relevant results. Please
%   note that only the English language is currently supported for this
%   functionality. Refer to examples for usage.
%
%  Examples
%   
%   Example 1: Simple search using a search term 'autosar'
%    slexOpen("autosar")
%        1. AUTOSARCounterExample
%        2. AuthorAUTOSARCompositionsInArchitectureModelExample
%        3.   > autosar_tpc_actuator
%        4.   > autosar_tpc_composition
%        5.   > autosar_tpc_controller
%        6.   > autosar_tpc_pedal_sensor
%        7.   > autosar_tpc_system
%        8.   > autosar_tpc_throttle_sensor1
%        9.   > autosar_tpc_throttle_sensor2
%       10.   > autosar_tpc_throttle_sensor_monitor
%       11. ConfigureAndSimulateAUTOSARFiMServiceCallsExample
%       12.   > autosar_bsw_fim
%       13.   > autosar_bsw_fimmonitor
%       14.   > autosar_bsw_fimoperationcycle
%       15.   > autosar_bsw_fimsensor1
%       16.   > autosar_bsw_fimsensor2
%       17. CreateAndConfigureAUTOSARAdaptiveSoftwareComponentExample
%       18. DesignAUTOSARComponentsExample
%       19.   > autosar_composition
%       20.   > autosar_swc_actuator
%       21.   > autosar_swc_controller
%       22.   > autosar_swc_monitor
%       23.   > autosar_swc_pedal_sensor
%       24.   > autosar_swc_throttle_sensor
%       25.   > autosar_system
%
%     Showing 1-25 of 68 matches. Enter (m) for more results.
%
%     Enter the example number you want to open (choose number) OR 
%     see more results (m) OR quit (q)
% 
%   Example 2: Search with additional filters
%    slexOpen('fluid','blocks',{'condenser'},'verbose','off')
%      1. ssc_rankine_cycle
%      2. ssc_refrigeration
%      3. sscfluids_condenser_evaporator
%      4. sscfluids_ev_thermal_management
%      5. sscfluids_refrigeration
%      Enter the example number you want to open (choose number) OR quit (q) : 
%
%   Example 3: Search using longer search queries
%    slexOpen('solar panel models in simulink')
%    slexOpen('fluid models using condenser')
%    slexOpen('how to make foucault pendulum in simulink')
%    slexOpen('pmsm models using discrete pulse generator','verbose','on')
%
%   Note: These search results will depend on models present on your system
%   and may therefore vary.
%
% Input Arguments:
%   str      - Input search term
%              '*' (default) | character vector | string
%   Note: Wildcard ('*') matching is also supported for matches in str.
%   Therefore, 'condens*' will match 'condenser','condensation',etc.
%   'motor', 'condens*' and "solar panel" are valid examples of str.
%
% Name-Value Pair Arguments:
%   'blocks'         - Specifies blocks in the search criteria
%                    '' (default) | char | string | cell array of char/string
%
%                    This limits the models displayed in model finder based
%                    on blocks present in the models.
%                    'gain', "gain", {'gain' 'mux'} and {"mux" "pi controller"}
%                    are valid examples for values specified using 'blocks'
%
%   'verbose'        - Toggle verbose on or off
%                    'off' (default) | 'on'
%                    The results are displayed with the path of the matched
%                    models and the matching characters from str. Whenever
%                    available, information about where the str was found
%                    (Name, Annotations, Description, etc.) in the model
%                    will also be mentioned.
%
%   'resultsPerPage' - Specify number of results per page
%                    20 (default) | positive integer
%                    This will set the number of results to be displayed on
%                    one page to the specified value. Please note that the
%                    number of results actually displayed may vary to
%                    preserve the model hierarchy in output.
%
% See also: modelfinder

% Copyright 2016-2021 The MathWorks, Inc.

    arguments
        str {mustBeNonzeroLengthText,mustBeTextScalar} = '*'
        options.blocks {mustBeText} = ''
        options.verbose {mustBeMember(options.verbose,{'on','off'})} = 'off'
        options.resultsPerPage (1,1) {mustBeInteger,mustBePositive} = 20
    end

    modelfinder.internal.open(str,...
                     'blocks',options.blocks,...
                     'verbose',options.verbose,...
                     'resultsPerPage',options.resultsPerPage);
end

% LocalWords:  tpc MService bsw fim fimmonitor fimoperationcycle fimsensor ssc rankine sscfluids ev
% LocalWords:  foucault pmsm condens
