mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 16:00:39 +01:00
[v0.95] Add --raw option
This commit is contained in:
@@ -20,6 +20,7 @@ static const char *SYTLES_STR_LIST[] = {
|
||||
enum {
|
||||
ARG_CHAR_STYLE,
|
||||
ARG_CHAR_COLOR,
|
||||
ARG_CHAR_RAW,
|
||||
ARG_CHAR_HELP,
|
||||
ARG_CHAR_DEBUG,
|
||||
ARG_CHAR_VERBOSE,
|
||||
@@ -29,6 +30,7 @@ enum {
|
||||
struct args_struct {
|
||||
bool debug_flag;
|
||||
bool help_flag;
|
||||
bool raw_flag;
|
||||
bool verbose_flag;
|
||||
bool version_flag;
|
||||
STYLE style;
|
||||
@@ -57,6 +59,10 @@ bool show_debug() {
|
||||
return args.debug_flag;
|
||||
}
|
||||
|
||||
bool show_raw() {
|
||||
return args.raw_flag;
|
||||
}
|
||||
|
||||
bool verbose_enabled() {
|
||||
return args.verbose_flag;
|
||||
}
|
||||
@@ -165,6 +171,7 @@ bool parse_args(int argc, char* argv[]) {
|
||||
|
||||
bool color_flag = false;
|
||||
args.debug_flag = false;
|
||||
args.raw_flag = false;
|
||||
args.verbose_flag = false;
|
||||
args.help_flag = false;
|
||||
args.style = STYLE_EMPTY;
|
||||
@@ -173,6 +180,7 @@ bool parse_args(int argc, char* argv[]) {
|
||||
static struct option long_options[] = {
|
||||
{"style", required_argument, 0, ARG_CHAR_STYLE },
|
||||
{"color", required_argument, 0, ARG_CHAR_COLOR },
|
||||
{"raw", no_argument, 0, ARG_CHAR_RAW },
|
||||
{"help", no_argument, 0, ARG_CHAR_HELP },
|
||||
{"debug", no_argument, 0, ARG_CHAR_DEBUG },
|
||||
{"verbose", no_argument, 0, ARG_CHAR_VERBOSE },
|
||||
@@ -205,6 +213,13 @@ bool parse_args(int argc, char* argv[]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(c == ARG_CHAR_RAW) {
|
||||
if(args.raw_flag) {
|
||||
printErr("Raw option specified more than once");
|
||||
return false;
|
||||
}
|
||||
args.raw_flag = true;
|
||||
}
|
||||
else if(c == ARG_CHAR_HELP) {
|
||||
if(args.help_flag) {
|
||||
printErr("Help option specified more than once");
|
||||
|
||||
@@ -30,6 +30,7 @@ enum {
|
||||
|
||||
bool parse_args(int argc, char* argv[]);
|
||||
bool show_help();
|
||||
bool show_raw();
|
||||
bool show_debug();
|
||||
bool show_version();
|
||||
bool verbose_enabled();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
static const char* VERSION = "0.95";
|
||||
|
||||
void print_help(char *argv[]) {
|
||||
printf("Usage: %s [--version] [--help] [--debug] [--style \"fancy\"|\"retro\"|\"legacy\"] [--color \"intel\"|\"amd\"|'R,G,B:R,G,B:R,G,B:R,G,B']\n\n", argv[0]);
|
||||
printf("Usage: %s [--version] [--help] [--debug] [--raw] [--style \"fancy\"|\"retro\"|\"legacy\"] [--color \"intel\"|\"amd\"|'R,G,B:R,G,B:R,G,B:R,G,B']\n\n", argv[0]);
|
||||
|
||||
printf("Options: \n\
|
||||
--color Set the color scheme. By default, cpufetch uses the system color scheme. This option \n\
|
||||
@@ -31,7 +31,8 @@ void print_help(char *argv[]) {
|
||||
--style Set the style of CPU art: \n\
|
||||
* \"fancy\": Default style \n\
|
||||
* \"retro\": Old cpufetch style \n\
|
||||
* \"legacy\": Fallback style for terminals that does not support colors \n\n");
|
||||
* \"legacy\": Fallback style for terminals that does not support colors \n\n\
|
||||
--raw Dump raw cpuid information \n\n");
|
||||
|
||||
#ifdef ARCH_X86
|
||||
printf(" --debug Prints CPU model and cpuid levels (debug purposes)\n\n");
|
||||
@@ -81,6 +82,12 @@ int main(int argc, char* argv[]) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if(show_raw()) {
|
||||
print_version();
|
||||
print_raw(cpu);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if(print_cpufetch(cpu, get_style(), get_colors()))
|
||||
return EXIT_SUCCESS;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user