From 17b614a2789db2c1249ee5c5a81bad5f09973cda Mon Sep 17 00:00:00 2001 From: speedie Date: Wed, 16 Aug 2023 08:22:23 +0200 Subject: [PATCH] Add `-q` quiet option --- mcopy.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/mcopy.cpp b/mcopy.cpp index 5f4f5da..755593e 100644 --- a/mcopy.cpp +++ b/mcopy.cpp @@ -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];