Compare commits

...
2 Commits
Author SHA1 Message Date
Riyyi 592ee124cb Manager: Do not print debugging output on release mode 2022-01-31 20:42:17 +01:00
Riyyi 8cb2affc50 Manager: Clean up main.cpp 2022-01-31 20:26:44 +01:00
2 changed files with 20 additions and 29 deletions
+6 -29
View File
@@ -4,32 +4,16 @@
* SPDX-License-Identifier: MIT
*/
#include <cstdio> // fprintf, perror, stderr
#include <filesystem>
#include <cstdio> // fprintf, stderr
#include <string>
#include <unistd.h> // gethostname
#include <vector>
#include "config.h"
#include "dotfile.h"
#include "package.h"
#include "util/argparser.h"
#include "util/file.h"
#include "util/system.h"
#include "util/timer.h"
// void* operator new(size_t size)
// {
// std::cout << "@Allocating '" << size << "' bytes" << std::endl;
// return std::malloc(size);
// }
// void operator delete(void* pointer, size_t size)
// {
// std::cout << "@Freeing '" << size << "' bytes" << std::endl;
// free(pointer);
// }
int main(int argc, const char* argv[])
{
bool fileOperation = false;
@@ -63,7 +47,9 @@ int main(int argc, const char* argv[])
return 1;
}
#ifndef NDEBUG
Util::Timer t;
#endif
Config::the().setVerbose(verbose);
@@ -119,18 +105,9 @@ int main(int argc, const char* argv[])
// TODO open manpage
}
printf("%fms\n", t.elapsedNanoseconds() / 1000000.0);
#ifndef NDEBUG
printf("%fms\n", t.elapsedNanoseconds() / 1000000.0);
#endif
return 0;
}
// cp -a <> <>
// -a = -dR --preserve=all
// -d = --no-dereference --preserve=links
// -P, --no-dereference = never follow symbolic links in SOURCE
// -R = recursive
// --preserve = preserve attributes (default: mode,ownership,timestamps), additional: context,links,xattr,all
// # Files that are stored in the repository but shouldn't get copied (regex)
// excludeFiles="${0#??}|$packageFile|.*.md$|.*README.org$|.git|screenshot.png"
// exclude: files, folders, ends-with
+14
View File
@@ -1,3 +1,9 @@
/*
* Copyright (C) 2021-2022 Riyyi
*
* SPDX-License-Identifier: MIT
*/
#include <algorithm> // find_if
#include <cstddef> // size_t
#include <cstdio> // printf
@@ -75,13 +81,18 @@ bool ArgParser::parseShortOption(std::string_view option, std::string_view next)
{
bool result = true;
#ifndef NDEBUG
printf("Parsing short option: '%s'\n", option.data());
#endif
char c;
std::string_view value;
for (size_t i = 0; i < option.size(); ++i) {
c = option.at(i);
#ifndef NDEBUG
printf("short '%c'\n", c);
#endif
auto foundOption = std::find_if(m_options.begin(), m_options.end(), [&c](Option& it) -> bool {
return it.shortName == c;
@@ -263,7 +274,10 @@ bool ArgParser::parse(int argc, const char* argv[])
std::string_view argument;
std::string_view next;
for (; m_optionIndex < (size_t)argc; ++m_optionIndex) {
#ifndef NDEBUG
printf("argv[%zu]: %s\n", m_optionIndex, argv[m_optionIndex]);
#endif
// Get the current and next parameter
argument = argv[m_optionIndex];