|
11 | 11 | // Things only needed by fastfetch |
12 | 12 | typedef struct FFdata |
13 | 13 | { |
14 | | - FFvaluestore valuestore; |
| 14 | + FFvaluestore customWithKey; //Prints with key |
| 15 | + FFvaluestore customKeyless; //Prints without |
15 | 16 | FFstrbuf structure; |
16 | 17 | bool loadUserConfig; |
17 | 18 | } FFdata; |
@@ -668,6 +669,27 @@ static uint32_t optionParseUInt32(const char* key, const char* value) |
668 | 669 | return num; |
669 | 670 | } |
670 | 671 |
|
| 672 | +static void optionParseCustom(const char* key, const char* value, FFvaluestore* valuestore) |
| 673 | +{ |
| 674 | + if(value == NULL) |
| 675 | + { |
| 676 | + fprintf(stderr, "Error: usage: %s <key=value>\n", key); |
| 677 | + exit(411); |
| 678 | + } |
| 679 | + |
| 680 | + char* separator = strchr(value, '='); |
| 681 | + |
| 682 | + if(separator == NULL) |
| 683 | + { |
| 684 | + fprintf(stderr, "Error: usage: %s <key=value>, '=' missing\n", key); |
| 685 | + exit(412); |
| 686 | + } |
| 687 | + |
| 688 | + *separator = '\0'; |
| 689 | + |
| 690 | + ffValuestoreSet(valuestore, value, separator + 1); |
| 691 | +} |
| 692 | + |
671 | 693 | static void parseOption(FFinstance* instance, FFdata* data, const char* key, const char* value) |
672 | 694 | { |
673 | 695 | /////////////////////// |
@@ -879,25 +901,9 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con |
879 | 901 | else if(strcasecmp(key, "-c") == 0 || strcasecmp(key, "--color") == 0) |
880 | 902 | optionParseColor(key, value, &instance->config.mainColor); |
881 | 903 | else if(strcasecmp(key, "--set") == 0) |
882 | | - { |
883 | | - if(value == NULL) |
884 | | - { |
885 | | - fprintf(stderr, "Error: usage: %s <key=value>\n", key); |
886 | | - exit(411); |
887 | | - } |
888 | | - |
889 | | - char* separator = strchr(value, '='); |
890 | | - |
891 | | - if(separator == NULL) |
892 | | - { |
893 | | - fprintf(stderr, "Error: usage: %s <key=value>, '=' missing\n", key); |
894 | | - exit(412); |
895 | | - } |
896 | | - |
897 | | - *separator = '\0'; |
898 | | - |
899 | | - ffValuestoreSet(&data->valuestore, value, separator + 1); |
900 | | - } |
| 904 | + optionParseCustom(key, value, &data->customWithKey); |
| 905 | + else if(strcasecmp(key, "--set-keyless") == 0) |
| 906 | + optionParseCustom(key, value, &data->customKeyless); |
901 | 907 |
|
902 | 908 | //////////////////////////////// |
903 | 909 | //Format + Key + Error options// |
@@ -1279,13 +1285,20 @@ static void parseArguments(FFinstance* instance, FFdata* data, int argc, const c |
1279 | 1285 |
|
1280 | 1286 | static void parseStructureCommand(FFinstance* instance, FFdata* data, const char* line) |
1281 | 1287 | { |
1282 | | - const char* setValue = ffValuestoreGet(&data->valuestore, line); |
| 1288 | + const char* setValue = ffValuestoreGet(&data->customWithKey, line); |
1283 | 1289 | if(setValue != NULL) |
1284 | 1290 | { |
1285 | 1291 | ffPrintCustom(instance, line, setValue); |
1286 | 1292 | return; |
1287 | 1293 | } |
1288 | 1294 |
|
| 1295 | + setValue = ffValuestoreGet(&data->customKeyless, line); |
| 1296 | + if(setValue != NULL) |
| 1297 | + { |
| 1298 | + ffPrintCustom(instance, NULL, setValue); |
| 1299 | + return; |
| 1300 | + } |
| 1301 | + |
1289 | 1302 | if(strcasecmp(line, "break") == 0) |
1290 | 1303 | ffPrintBreak(instance); |
1291 | 1304 | else if(strcasecmp(line, "title") == 0) |
@@ -1373,7 +1386,8 @@ int main(int argc, const char** argv) |
1373 | 1386 |
|
1374 | 1387 | //Data stores things only needed for the configuration of fastfetch |
1375 | 1388 | FFdata data; |
1376 | | - ffValuestoreInit(&data.valuestore); |
| 1389 | + ffValuestoreInit(&data.customWithKey); |
| 1390 | + ffValuestoreInit(&data.customKeyless); |
1377 | 1391 | ffStrbufInitA(&data.structure, 256); |
1378 | 1392 | data.loadUserConfig = true; |
1379 | 1393 |
|
|
0 commit comments