mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 07:50:40 +01:00
[v1.03] Print version when reporting an error or bug (implements #172)
This commit is contained in:
@@ -20,6 +20,37 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ARCH_X86
|
||||||
|
static const char* ARCH_STR = "x86_64 build";
|
||||||
|
#include "../x86/cpuid.h"
|
||||||
|
#elif ARCH_PPC
|
||||||
|
static const char* ARCH_STR = "PowerPC build";
|
||||||
|
#include "../ppc/ppc.h"
|
||||||
|
#elif ARCH_ARM
|
||||||
|
static const char* ARCH_STR = "ARM build";
|
||||||
|
#include "../arm/midr.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
static const char* OS_STR = "Android";
|
||||||
|
#else
|
||||||
|
static const char* OS_STR = "Linux";
|
||||||
|
#endif
|
||||||
|
#elif __FreeBSD__
|
||||||
|
static const char* OS_STR = "FreeBSD";
|
||||||
|
#elif _WIN32
|
||||||
|
static const char* OS_STR = "Windows";
|
||||||
|
#elif defined __APPLE__ || __MACH__
|
||||||
|
static const char* OS_STR = "macOS";
|
||||||
|
#else
|
||||||
|
static const char* OS_STR = "Unknown OS";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GIT_FULL_VERSION
|
||||||
|
static const char* VERSION = "1.03";
|
||||||
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
LOG_LEVEL_NORMAL,
|
LOG_LEVEL_NORMAL,
|
||||||
LOG_LEVEL_VERBOSE
|
LOG_LEVEL_VERBOSE
|
||||||
@@ -47,6 +78,8 @@ void printErr(const char *fmt, ...) {
|
|||||||
vsnprintf(buffer,buffer_size, fmt, args);
|
vsnprintf(buffer,buffer_size, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
fprintf(stderr,RED "[ERROR]: "RESET "%s\n",buffer);
|
fprintf(stderr,RED "[ERROR]: "RESET "%s\n",buffer);
|
||||||
|
fprintf(stderr,"[VERSION]: ");
|
||||||
|
print_version(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printBug(const char *fmt, ...) {
|
void printBug(const char *fmt, ...) {
|
||||||
@@ -57,6 +90,8 @@ void printBug(const char *fmt, ...) {
|
|||||||
vsnprintf(buffer,buffer_size, fmt, args);
|
vsnprintf(buffer,buffer_size, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
fprintf(stderr,RED "[ERROR]: "RESET "%s\n",buffer);
|
fprintf(stderr,RED "[ERROR]: "RESET "%s\n",buffer);
|
||||||
|
fprintf(stderr,"[VERSION]: ");
|
||||||
|
print_version(stderr);
|
||||||
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
||||||
fprintf(stderr, "Please, create a new issue with this error message, the output of 'cpufetch' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues\n");
|
fprintf(stderr, "Please, create a new issue with this error message, the output of 'cpufetch' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues\n");
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
@@ -123,3 +158,10 @@ void* erealloc(void *ptr, size_t size) {
|
|||||||
return newptr;
|
return newptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_version(FILE *restrict stream) {
|
||||||
|
#ifdef GIT_FULL_VERSION
|
||||||
|
fprintf(stream, "cpufetch %s (%s %s)\n", GIT_FULL_VERSION, OS_STR, ARCH_STR);
|
||||||
|
#else
|
||||||
|
fprintf(stream, "cpufetch v%s (%s %s)\n", VERSION, OS_STR, ARCH_STR);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,5 +17,6 @@ char *strremove(char *str, const char *sub);
|
|||||||
void* emalloc(size_t size);
|
void* emalloc(size_t size);
|
||||||
void* ecalloc(size_t nmemb, size_t size);
|
void* ecalloc(size_t nmemb, size_t size);
|
||||||
void* erealloc(void *ptr, size_t size);
|
void* erealloc(void *ptr, size_t size);
|
||||||
|
void print_version(FILE *restrict stream);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,37 +6,6 @@
|
|||||||
#include "printer.h"
|
#include "printer.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#ifdef ARCH_X86
|
|
||||||
static const char* ARCH_STR = "x86_64 build";
|
|
||||||
#include "../x86/cpuid.h"
|
|
||||||
#elif ARCH_PPC
|
|
||||||
static const char* ARCH_STR = "PowerPC build";
|
|
||||||
#include "../ppc/ppc.h"
|
|
||||||
#elif ARCH_ARM
|
|
||||||
static const char* ARCH_STR = "ARM build";
|
|
||||||
#include "../arm/midr.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
static const char* OS_STR = "Android";
|
|
||||||
#else
|
|
||||||
static const char* OS_STR = "Linux";
|
|
||||||
#endif
|
|
||||||
#elif __FreeBSD__
|
|
||||||
static const char* OS_STR = "FreeBSD";
|
|
||||||
#elif _WIN32
|
|
||||||
static const char* OS_STR = "Windows";
|
|
||||||
#elif defined __APPLE__ || __MACH__
|
|
||||||
static const char* OS_STR = "macOS";
|
|
||||||
#else
|
|
||||||
static const char* OS_STR = "Unknown OS";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef GIT_FULL_VERSION
|
|
||||||
static const char* VERSION = "1.03";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void print_help(char *argv[]) {
|
void print_help(char *argv[]) {
|
||||||
const char **t = args_str;
|
const char **t = args_str;
|
||||||
const char *c = args_chr;
|
const char *c = args_chr;
|
||||||
@@ -108,14 +77,6 @@ void print_help(char *argv[]) {
|
|||||||
printf(" To correctly measure peak performance, see: https://github.com/Dr-Noob/peakperf\n");
|
printf(" To correctly measure peak performance, see: https://github.com/Dr-Noob/peakperf\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_version() {
|
|
||||||
#ifdef GIT_FULL_VERSION
|
|
||||||
printf("cpufetch %s (%s %s)\n", GIT_FULL_VERSION, OS_STR, ARCH_STR);
|
|
||||||
#else
|
|
||||||
printf("cpufetch v%s (%s %s)\n", VERSION, OS_STR, ARCH_STR);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
if(!parse_args(argc,argv))
|
if(!parse_args(argc,argv))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@@ -126,7 +87,7 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(show_version()) {
|
if(show_version()) {
|
||||||
print_version();
|
print_version(stdout);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +98,7 @@ int main(int argc, char* argv[]) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
if(show_debug()) {
|
if(show_debug()) {
|
||||||
print_version();
|
print_version(stdout);
|
||||||
print_debug(cpu);
|
print_debug(cpu);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -145,7 +106,7 @@ int main(int argc, char* argv[]) {
|
|||||||
// TODO: This should be moved to the end of args.c
|
// TODO: This should be moved to the end of args.c
|
||||||
if(show_raw()) {
|
if(show_raw()) {
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
print_version();
|
print_version(stdout);
|
||||||
print_raw(cpu);
|
print_raw(cpu);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user