|
|
@ -99,6 +99,18 @@ void Dotfile::list(const std::vector<std::string>& targets) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Dotfile::pull(const std::vector<std::string>& targets) |
|
|
|
void Dotfile::pull(const std::vector<std::string>& targets) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pullOrPush(SyncType::Pull, targets); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Dotfile::push(const std::vector<std::string>& targets) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pullOrPush(SyncType::Push, targets); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Dotfile::pullOrPush(SyncType type, const std::vector<std::string>& targets) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::vector<std::string> dotfiles; |
|
|
|
std::vector<std::string> dotfiles; |
|
|
|
std::vector<size_t> homeIndices; |
|
|
|
std::vector<size_t> homeIndices; |
|
|
@ -115,6 +127,7 @@ void Dotfile::pull(const std::vector<std::string>& targets) |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (type == SyncType::Pull) { |
|
|
|
sync( |
|
|
|
sync( |
|
|
|
dotfiles, homeIndices, systemIndices, |
|
|
|
dotfiles, homeIndices, systemIndices, |
|
|
|
[](std::string* paths, const std::string& homeFile, const std::string& homeDirectory) { |
|
|
|
[](std::string* paths, const std::string& homeFile, const std::string& homeDirectory) { |
|
|
@ -129,25 +142,8 @@ void Dotfile::pull(const std::vector<std::string>& targets) |
|
|
|
paths[0] = systemFile.substr(s_workingDirectorySize); |
|
|
|
paths[0] = systemFile.substr(s_workingDirectorySize); |
|
|
|
paths[1] = systemFile; |
|
|
|
paths[1] = systemFile; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Dotfile::push(const std::vector<std::string>& targets) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
std::vector<std::string> dotfiles; |
|
|
|
|
|
|
|
std::vector<size_t> homeIndices; |
|
|
|
|
|
|
|
std::vector<size_t> systemIndices; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Separate home and system targets
|
|
|
|
|
|
|
|
forEachDotfile(targets, [&](const std::filesystem::directory_entry& path, size_t index) { |
|
|
|
|
|
|
|
dotfiles.push_back(path.path().string()); |
|
|
|
|
|
|
|
if (isSystemTarget(path.path().string())) { |
|
|
|
|
|
|
|
systemIndices.push_back(index); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
homeIndices.push_back(index); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sync( |
|
|
|
sync( |
|
|
|
dotfiles, homeIndices, systemIndices, |
|
|
|
dotfiles, homeIndices, systemIndices, |
|
|
|
[](std::string* paths, const std::string& homeFile, const std::string& homeDirectory) { |
|
|
|
[](std::string* paths, const std::string& homeFile, const std::string& homeDirectory) { |
|
|
@ -162,10 +158,9 @@ void Dotfile::push(const std::vector<std::string>& targets) |
|
|
|
paths[0] = systemFile; |
|
|
|
paths[0] = systemFile; |
|
|
|
paths[1] = systemFile.substr(s_workingDirectorySize); |
|
|
|
paths[1] = systemFile.substr(s_workingDirectorySize); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Dotfile::sync(const std::vector<std::string>& paths, const std::vector<size_t>& homeIndices, const std::vector<size_t>& systemIndices, |
|
|
|
void Dotfile::sync(const std::vector<std::string>& paths, const std::vector<size_t>& homeIndices, const std::vector<size_t>& systemIndices, |
|
|
|
const std::function<void(std::string*, const std::string&, const std::string&)>& generateHomePaths, |
|
|
|
const std::function<void(std::string*, const std::string&, const std::string&)>& generateHomePaths, |
|
|
|
const std::function<void(std::string*, const std::string&)>& generateSystemPaths) |
|
|
|
const std::function<void(std::string*, const std::string&)>& generateSystemPaths) |
|
|
|