Add -q quiet option

This commit is contained in:
Jacob 2023-08-16 08:22:23 +02:00
parent e97b4496c8
commit 17b614a278

View file

@ -18,15 +18,18 @@
#endif
bool ask = true;
bool quiet = false;
void help() {
std::cout <<
"mcopy " << VERSION << "\n\n" <<
"mcopy -f, --format Specify a format to output files using\n" <<
"mcopy -a, --ask Ask the user if metadata cannot be retrieved from file\n" <<
"mcopy -na, --no-ask Don't ask if metadata cannot be retrieved from file\n" <<
"mcopy -h, --help Display help\n" <<
"mcopy -v, --version Display version\n" <<
"mcopy -f, --format Specify a format to output files using\n" <<
"mcopy -a, --ask Ask the user if metadata cannot be retrieved from file\n" <<
"mcopy -na, --no-ask Don't ask if metadata cannot be retrieved from file\n" <<
"mcopy -q, --quiet Don't print status messages. Warnings will still be printed\n" <<
"mcopy -nq, --no-quiet Print status messages\n" <<
"mcopy -h, --help Display help\n" <<
"mcopy -v, --version Display version\n" <<
"\n" <<
"Example: mcopy --format \"/home/anon/Music/Albums/@A/@a/@n. @A - @t.flac\" \"~/Downloads/myflac1.flac\" \"~/Downloads/myflac2.flac\n" <<
"\n" <<
@ -60,8 +63,6 @@ void getMetadataFromFile(std::string format, std::string str) {
std::string artist = tag->artist().to8Bit(true);
std::string track = std::to_string(tag->track());
std::cout << "title: " << title << "\n";
// If information is missing, ask for the missing details
if (title.empty()) {
title = "Unknown";
@ -115,7 +116,7 @@ void getMetadataFromFile(std::string format, std::string str) {
if (!std::filesystem::copy_file(str, filename)) {
std::cerr << "mcopy: Failed to copy file " << str << " to " << filename << "\n";
exit(1);
} else {
} else if (!quiet) {
std::cout << "mcopy: Copied file " << str << " to " << filename << "\n";
}
}
@ -139,6 +140,10 @@ int main(int argc, char **argv) {
ask = true;
} else if (!arg.compare("-na") || !arg.compare("--no-ask")) {
ask = false;
} else if (!arg.compare("-q") || !arg.compare("--quiet")) {
quiet = true;
} else if (!arg.compare("-nq") || !arg.compare("--no-quiet")) {
quiet = false;
} else if (!arg.compare("-f") || !arg.compare("--format")) {
if (argc > i+1) {
format = argv[++i];