diff --git a/README.md b/README.md index 3a6dd31..5a2e33a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,13 @@ # zenith-cli +аргументы +zenith-cli --link="link" -p/--pastel --scheme-output="path" --wall-output="path" + +примеры использования + +если передать пустую строку, то файл сохранится в директории утилиты +./zenith-cli --link="https://w.wallhaven.cc/full/gw/wallhaven-gwd313.jpg" --wall-output="" + +ОБЯЗАТЕЛЬНО указывать в пути в конце /. потом мб добавлю проверку и автодополнение +./zenith-cli --link="https://w.wallhaven.cc/full/gw/wallhaven-gwd313.jpg" --wall-output="/home/ivan/" +./zenith-cli --link="https://w.wallhaven.cc/full/gw/wallhaven-gwd313.jpg" --wall-output="~/" \ No newline at end of file diff --git a/main.cpp b/main.cpp index 116dfd2..bf52a56 100644 --- a/main.cpp +++ b/main.cpp @@ -9,6 +9,8 @@ extern "C" { #include "libs/argparse.h" } +namespace fs = std::filesystem; + struct Scheme{ char fg_color[8]; char sub_fg_color[8]; @@ -37,7 +39,7 @@ int download_wall(const char* link, const char* path){ if(fp == NULL) { fprintf(stderr, \ - "ошибка: не удалось создать или открыть файл %s\n", path); + "ошибка: не удалось создать или открыть файл %s\n", path); curl_easy_cleanup(curl); curl_global_cleanup(); @@ -53,7 +55,7 @@ int download_wall(const char* link, const char* path){ if(res != CURLE_OK) { fprintf(stderr, "ошибка скачивания: %s\n", \ - curl_easy_strerror(res)); + curl_easy_strerror(res)); } fclose(fp); @@ -66,8 +68,6 @@ int download_wall(const char* link, const char* path){ return 0; } -namespace fs = std::filesystem; - int main(int argc, const char **argv) { const char* link = nullptr; @@ -92,7 +92,7 @@ int main(int argc, const char **argv) { struct argparse argparse; argparse_init(&argparse, options, nullptr, 0); argc = argparse_parse(&argparse, argc, argv); - + fs::path target_dir; if (raw_wall_path == nullptr || std::string(raw_wall_path).empty()){ @@ -109,25 +109,10 @@ int main(int argc, const char **argv) { target_dir = fs::path(path_str); } - fs::path full_path = target_dir / "wallpaper.jpg"; + std::string full_path_str(target_dir / "wallpaper.jpg"); + const char* full_path = full_path_str.c_str(); - std::cout << full_path << std::endl; - - // download_wall(link, path); + download_wall(link, full_path); return 0; -} -/* - -аргументы -zenith-cli --link="link" -p/--pastel --scheme-output="path" --wall-output="path" - -примеры использования - -если передать пустую строку, то файл сохранится в директории утилиты -./zenith-cli --link="https://w.wallhaven.cc/full/gw/wallhaven-gwd313.jpg" --wall-output="" - -ОБЯЗАТЕЛЬНО указывать в пути в конце /. потом мб добавлю проверку и автодополнение -./zenith-cli --link="https://w.wallhaven.cc/full/gw/wallhaven-gwd313.jpg" --wall-output="/home/ivan/" -./zenith-cli --link="https://w.wallhaven.cc/full/gw/wallhaven-gwd313.jpg" --wall-output="~/" -*/ \ No newline at end of file +} \ No newline at end of file