Skip to content

Commit

Permalink
args: add sep-title and sep-reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Aug 30, 2024
1 parent fd9fa70 commit 35bebfc
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion assets/config-examples/config_cool.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# This is really system depedent
layout = [
"${red}$<user.name>${0}@${cyan}$<os.hostname>",
"───────────────────────────",
"$<user.sep_reset>",
"${red}$<os.name> ${cyan} $<system.arch>${cyan} \\<- Arch ",
"${red} ^ ${green} $<os.kernel> \\<━━━┓",
"${red} | ${green}┃",
Expand Down
2 changes: 1 addition & 1 deletion assets/config-examples/config_modified.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

layout = [
"${red}$<user.name>${0}@${cyan}$<os.hostname>",
"───────────────────────────",
"$<user.sep_reset>",
"${red}OS -> $<os.name> $<system.arch>",
"${yellow}Host -> $<system.host>",
"${!#33ffa1}Init -> $<os.initsys_name>",
Expand Down
10 changes: 8 additions & 2 deletions cufetch.1
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,18 @@ Print the version along with the git branch it was built
\fB\-\-bg\-image\fR <path>
Path to image to be used in the background in GUI (put "disable" for disabling in the config)
.TP
\fB\-\-logo\-padding\-top\fR
\fB\-\-logo\-padding\-top\fR <num>
Padding of the logo from the top
.TP
\fB\-\-logo\-padding\-left\fR
\fB\-\-logo\-padding\-left\fR <num>
Padding of the logo from the left
.TP
\fB\-\-sep\-title\fR <string>
A char (or string) to use in $<user.title_sep>
.TP
\fB\-\-sep\-reset\fR <string>
A separetor (or string) that when ecountered, will automatically reset color
.TP
\fB\-\-gen\-config\fR [<path>]
Generate default config file to config folder (if path, it will generate to the path)
.br
Expand Down
4 changes: 2 additions & 2 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c
origin += asciiArt.at(i).length();
}

size_t spaces = (maxLineLength + (config.m_disable_source ? 1 : config.offset)) -
(i < asciiArt.size() ? pureAsciiArtLens.at(i) : 0);
const size_t& spaces = (maxLineLength + (config.m_disable_source ? 1 : config.offset)) -
(i < asciiArt.size() ? pureAsciiArtLens.at(i) : 0);

debug("spaces: {}", spaces);

Expand Down
13 changes: 12 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ A command-line system information tool (or neofetch like program), which its foc
--logo-padding-top <num> Padding of the logo from the top
--logo-padding-left <num> Padding of the logo from the left
--layout-padding-top <num> Padding of the layout from the top
--sep-title <string> A char (or string) to use in $<user.title_sep>
--sep-reset <string> A separetor (or string) that when ecountered, will automatically reset color
--gen-config [<path>] Generate default config file to config folder (if path, it will generate to the path)
Will ask for confirmation if file exists already
Expand Down Expand Up @@ -260,12 +262,15 @@ static bool parseargs(int argc, char* argv[], Config& config, const std::string_
{"distro", required_argument, 0, 'd'},
{"source-path", required_argument, 0, 's'},

{"sep-reset", required_argument, 0, "sep-reset"_fnv1a16},
{"sep-title", required_argument, 0, "sep-title"_fnv1a16},
{"logo-padding-top", required_argument, 0, "logo-padding-top"_fnv1a16},
{"logo-padding-left", required_argument, 0, "logo-padding-left"_fnv1a16},
{"layout-padding-top", required_argument, 0, "layout-padding-top"_fnv1a16},
{"bg-image", required_argument, 0, "bg-image"_fnv1a16},
{"color", required_argument, 0, "color"_fnv1a16},
{"gen-config", optional_argument, 0, "gen-config"_fnv1a16},

{0,0,0,0}
};

Expand Down Expand Up @@ -326,7 +331,7 @@ static bool parseargs(int argc, char* argv[], Config& config, const std::string_
case "color"_fnv1a16:
{
const std::string& optarg_str = optarg;
const size_t pos = optarg_str.find('=');
const size_t& pos = optarg_str.find('=');
if (pos == std::string::npos)
die("argument color '{}' does NOT have an equal sign '=' for separiting color name and value.\n"
"for more check with --help", optarg_str);
Expand All @@ -345,6 +350,12 @@ static bool parseargs(int argc, char* argv[], Config& config, const std::string_
config.generateConfig(configFile);
exit(EXIT_SUCCESS);

case "sep-reset"_fnv1a16:
config.sep_reset = optarg; break;

case "sep-title"_fnv1a16:
config.user_sep_title = optarg; break;

default:
return false;
}
Expand Down

0 comments on commit 35bebfc

Please sign in to comment.