function export(targetObject, options)
% EXPORT Internal implementation of TARGET.EXPORT.

%   Copyright 2021-2023 The MathWorks, Inc.

    arguments
        targetObject
        options.FileName
        options.FileType targetframework.internal.services.package.FileExportType = targetframework.internal.services.package.FileExportType.Matlab
        options.Overwrite
    end

    tr = targetframework.internal.repository.createTargetRepository();

    fileExport = targetframework.internal.services.package.createFileExport(tr, options.FileType);

    fileExport.OverwriteOutput = options.Overwrite;

    if ~isempty(options.FileName)
        fileExport.Path = options.FileName;
    end

    fileExport.run(targetObject);
end
