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