function launchui(appname,varargin)
%

% Copyright 2016-2019 MathWorks, Inc.

import matlab.internal.lang.capability.Capability;
Capability.require([Capability.Swing, Capability.ComplexSwing]);

% Check inputs, convert from string to char if needed
N = numel(varargin);
for n = 1:N
    validateattributes(varargin{n},{'char','string'},{'scalartext'}, ...
        appname,'',n)
    varargin{n} = char(varargin{n});
end

if (N == 1 && (strcmp(varargin{1},'-?') || strcmp(varargin{1},'/?')))
    help(appname)
    return
else
    com.mathworks.project.impl.plugin.PluginManager.allowMatlabThreadUse;
    if N == 0
        fcn = noinputfcn(appname);
        fcn();
    else
        if ~strcmp('hadoopCompiler', appname) && (strcmp('-build',varargin{1}) || strcmp('-package',varargin{1}))
            warning(message('Compiler:deploytool:DeploytoolFunctionalityToBeRemoved', appname));
        end
        com.mathworks.toolbox.compiler.plugin.DeploytoolCommandLineParser.parse(varargin,pwd);
    end
end


function fcn = noinputfcn(appname)

switch appname
    case 'deploytool'
        fcn = @com.mathworks.toolbox.compiler.desktop.DeploytoolLaunchPad.launch;
    case 'applicationCompiler'
        fcn = @com.mathworks.toolbox.compiler.desktop.DeploytoolLaunchPad.startStandaloneTool;
    case 'libraryCompiler'
        fcn = @com.mathworks.toolbox.compiler.desktop.DeploytoolLaunchPad.startLibraryTool;
    case 'hadoopCompiler'
        fcn = @com.mathworks.toolbox.compiler.desktop.DeploytoolLaunchPad.startMapReduceTool;
    case 'productionServerCompiler'
        fcn = @com.mathworks.toolbox.compiler.desktop.DeploytoolLaunchPad.startArchiveTool;
    case 'webAppCompiler'
        fcn = @com.mathworks.toolbox.compiler.desktop.DeploytoolLaunchPad.startWebAppsTool;
    otherwise
        error(message('MATLAB:class:UndefinedFunctionOrVariable',appname))
end
