изменено: перешел на с++. тк проще будет работать с фото. изменил скрипт сборки под c++
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
echo "начинаю сборку"
|
echo "начинаю сборку"
|
||||||
|
|
||||||
gcc main.c libs/argparse.c -o zenith-cli -lcurl
|
g++ main.cpp libs/argparse.c -o zenith-cli -lcurl
|
||||||
|
|
||||||
echo "сборкa завершена"
|
echo "сборкa завершена"
|
||||||
+34
-24
@@ -1,11 +1,14 @@
|
|||||||
#include <stdio.h>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <string>
|
||||||
#include <string.h>
|
#include <filesystem>
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "libs/argparse.h"
|
|
||||||
#include "curl/curl.h"
|
#include "curl/curl.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "libs/argparse.h"
|
||||||
|
}
|
||||||
|
|
||||||
struct Scheme{
|
struct Scheme{
|
||||||
char fg_color[8];
|
char fg_color[8];
|
||||||
char sub_fg_color[8];
|
char sub_fg_color[8];
|
||||||
@@ -63,16 +66,13 @@ int download_wall(const char* link, const char* path){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, const char **argv) {
|
||||||
const char* link = NULL;
|
|
||||||
const char* user_home = getenv("HOME");
|
|
||||||
const char* filename = "wallpaper.jpg";
|
|
||||||
|
|
||||||
char* raw_scheme_path = NULL;
|
const char* link = nullptr;
|
||||||
char* raw_wall_path = NULL;
|
const char* raw_scheme_path = nullptr;
|
||||||
|
const char* raw_wall_path = nullptr;
|
||||||
char wall_output[512];
|
|
||||||
char path[512];
|
|
||||||
|
|
||||||
int is_pastel = 0;
|
int is_pastel = 0;
|
||||||
|
|
||||||
@@ -90,20 +90,30 @@ int main(int argc, const char **argv) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct argparse argparse;
|
struct argparse argparse;
|
||||||
argparse_init(&argparse, options, NULL, 0);
|
argparse_init(&argparse, options, nullptr, 0);
|
||||||
argc = argparse_parse(&argparse, argc, argv);
|
argc = argparse_parse(&argparse, argc, argv);
|
||||||
|
|
||||||
if (raw_wall_path == NULL){
|
fs::path target_dir;
|
||||||
wall_output[0] = '.';
|
|
||||||
wall_output[1] = '/';
|
|
||||||
}
|
|
||||||
else if (raw_wall_path[0] == '~'){
|
|
||||||
snprintf(wall_output, sizeof(wall_output), \
|
|
||||||
"%s%s", user_home, raw_wall_path + 1);
|
|
||||||
}
|
|
||||||
snprintf(path, sizeof(path), "%s%s", wall_output, filename);
|
|
||||||
|
|
||||||
download_wall(link, path);
|
if (raw_wall_path == nullptr || std::string(raw_wall_path).empty()){
|
||||||
|
target_dir = fs::current_path();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
std::string path_str(raw_wall_path);
|
||||||
|
if (path_str[0] == '~'){
|
||||||
|
const char* user_home = std::getenv("HOME");
|
||||||
|
if (user_home){
|
||||||
|
path_str.replace(0, 1, user_home);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
target_dir = fs::path(path_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
fs::path full_path = target_dir / "wallpaper.jpg";
|
||||||
|
|
||||||
|
std::cout << full_path << std::endl;
|
||||||
|
|
||||||
|
// download_wall(link, path);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user