mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 08:13:44 +01:00
Chore: run clang-format
```bash find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) ! -path "src/3rdparty/*" -print0 | xargs -0 clang-format -i ```
This commit is contained in:
+27
-39
@@ -4,70 +4,60 @@
|
||||
#include "detection/terminalshell/terminalshell.h"
|
||||
#include "modules/shell/shell.h"
|
||||
|
||||
bool ffPrintShell(FFShellOptions* options)
|
||||
{
|
||||
bool ffPrintShell(FFShellOptions* options) {
|
||||
const FFShellResult* result = ffDetectShell();
|
||||
|
||||
if(result->processName.length == 0)
|
||||
{
|
||||
if (result->processName.length == 0) {
|
||||
ffPrintError(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Couldn't detect shell");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
if (options->moduleArgs.outputFormat.length == 0) {
|
||||
ffPrintLogoAndKey(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
ffStrbufWriteTo(&result->prettyName, stdout);
|
||||
|
||||
if(result->version.length > 0)
|
||||
{
|
||||
if (result->version.length > 0) {
|
||||
putchar(' ');
|
||||
ffStrbufWriteTo(&result->version, stdout);
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_ARG(result->processName, "process-name"),
|
||||
FF_ARG(result->exe, "exe"),
|
||||
FF_ARG(result->exeName, "exe-name"),
|
||||
FF_ARG(result->version, "version"),
|
||||
FF_ARG(result->pid, "pid"),
|
||||
FF_ARG(result->prettyName, "pretty-name"),
|
||||
FF_ARG(result->exePath, "exe-path"),
|
||||
FF_ARG(result->tty, "tty"),
|
||||
}));
|
||||
FF_ARG(result->processName, "process-name"),
|
||||
FF_ARG(result->exe, "exe"),
|
||||
FF_ARG(result->exeName, "exe-name"),
|
||||
FF_ARG(result->version, "version"),
|
||||
FF_ARG(result->pid, "pid"),
|
||||
FF_ARG(result->prettyName, "pretty-name"),
|
||||
FF_ARG(result->exePath, "exe-path"),
|
||||
FF_ARG(result->tty, "tty"),
|
||||
}));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffParseShellJsonObject(FFShellOptions* options, yyjson_val* module)
|
||||
{
|
||||
void ffParseShellJsonObject(FFShellOptions* options, yyjson_val* module) {
|
||||
yyjson_val *key, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key, val)
|
||||
{
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
yyjson_obj_foreach (module, idx, max, key, val) {
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", unsafe_yyjson_get_str(key));
|
||||
}
|
||||
}
|
||||
|
||||
void ffGenerateShellJsonConfig(FFShellOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
void ffGenerateShellJsonConfig(FFShellOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
|
||||
}
|
||||
|
||||
bool ffGenerateShellJsonResult(FF_MAYBE_UNUSED FFShellOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
bool ffGenerateShellJsonResult(FF_MAYBE_UNUSED FFShellOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
const FFShellResult* result = ffDetectShell();
|
||||
|
||||
if(result->processName.length == 0)
|
||||
{
|
||||
if (result->processName.length == 0) {
|
||||
yyjson_mut_obj_add_str(doc, module, "error", "Couldn't detect shell");
|
||||
return false;
|
||||
}
|
||||
@@ -81,21 +71,20 @@ bool ffGenerateShellJsonResult(FF_MAYBE_UNUSED FFShellOptions* options, yyjson_m
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "processName", &result->processName);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "prettyName", &result->prettyName);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "version", &result->version);
|
||||
if (result->tty >= 0)
|
||||
if (result->tty >= 0) {
|
||||
yyjson_mut_obj_add_int(doc, obj, "tty", result->tty);
|
||||
else
|
||||
} else {
|
||||
yyjson_mut_obj_add_null(doc, obj, "tty");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffInitShellOptions(FFShellOptions* options)
|
||||
{
|
||||
void ffInitShellOptions(FFShellOptions* options) {
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
void ffDestroyShellOptions(FFShellOptions* options)
|
||||
{
|
||||
void ffDestroyShellOptions(FFShellOptions* options) {
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -117,5 +106,4 @@ FFModuleBaseInfo ffShellModuleInfo = {
|
||||
{"Shell pretty name", "pretty-name"},
|
||||
{"Shell full exe path", "exe-path"},
|
||||
{"Shell tty used", "tty"},
|
||||
}))
|
||||
};
|
||||
}))};
|
||||
|
||||
Reference in New Issue
Block a user