function addLibrary(lib, NVPArgs)

    arguments
        lib(1,1) bioinfo.pipeline.library.Library
        NVPArgs.Overwrite(1,1) logical = false
    end

    libFolder = bioinfo.pipeline.internal.library.libraryFolder;
    
    libFile = fullfile(libFolder, sprintf("%s.mat", lib.Name));

    if isfile(libFile) && ~NVPArgs.Overwrite
        error(message("bioinfo:Library:addLibrary:LibraryExists", lib.Name));
    end

    bioinfo.pipeline.internal.library.checkBuiltinConflicts(lib);
    bioinfo.pipeline.library.saveLibrary(lib, libFolder, Overwrite=true);
end
% Copyright 2023 The MathWorks, Inc.

