Skip to content

Commit

Permalink
args: add --sep-reset-after
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Sep 4, 2024
1 parent 05f45e1 commit 59cb489
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
3 changes: 3 additions & 0 deletions cufetch.1
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ A char (or string) to use in $<user.title_sep>
\fB\-\-sep\-reset\fR <string>
A separetor (or string) that when ecountered, will automatically reset color
.TP
\fB\-\-sep\-reset\-after\fR [<num>]
Reset color either before of after 'sep-reset' (1 = after && 0 = before)
.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 include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ sep-title = "-"
sep-reset = ":"
# Should we reset color after or before the separetor?
# true = after ("test:${0} ")
# false = before ("test${0}: ")
# true = after ("test ->${0} ")
# false = before ("test ${0}-> ")
sep-reset-after = false
# Offset between the ascii art and the layout
Expand Down
2 changes: 1 addition & 1 deletion src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Window::Window(const Config& config, const colors_t& colors, const std::string_v
if (useImage && !config.m_disable_source)
{
Glib::RefPtr<Gdk::PixbufAnimation> img = Gdk::PixbufAnimation::create_from_file(path.data());
m_img = Gtk::manage(new Gtk::Image(img));
m_img = Gtk::manage(new Gtk::Image(img));
m_img->set(img);
m_img->set_alignment(Gtk::ALIGN_CENTER);
m_box.pack_start(*m_img, Gtk::PACK_SHRINK);
Expand Down
35 changes: 22 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ A command-line system information tool (or neofetch like program), which its foc
--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
--sep-reset-after [<num>] Reset color either before of after 'sep-reset' (1 = after && 0 = before)
--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 @@ -262,6 +263,7 @@ static bool parseargs(int argc, char* argv[], Config& config, const std::string_

{"sep-reset", required_argument, 0, "sep-reset"_fnv1a16},
{"sep-title", required_argument, 0, "sep-title"_fnv1a16},
{"sep-reset-after", optional_argument, 0, "sep-reset-after"_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},
Expand Down Expand Up @@ -327,19 +329,19 @@ static bool parseargs(int argc, char* argv[], Config& config, const std::string_
config.gui_bg_image = optarg; break;

case "color"_fnv1a16:
{
const std::string& optarg_str = optarg;
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);

const std::string& name = optarg_str.substr(0, pos);
const std::string& value = optarg_str.substr(pos + 1);
config.m_arg_colors_name.push_back(name);
config.m_arg_colors_value.push_back(value);
}
break;
{
const std::string& optarg_str = optarg;
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);

const std::string& name = optarg_str.substr(0, pos);
const std::string& value = optarg_str.substr(pos + 1);
config.m_arg_colors_name.push_back(name);
config.m_arg_colors_value.push_back(value);
}
break;

case "gen-config"_fnv1a16:
if (OPTIONAL_ARGUMENT_IS_PRESENT)
Expand All @@ -354,6 +356,13 @@ static bool parseargs(int argc, char* argv[], Config& config, const std::string_
case "sep-title"_fnv1a16:
config.user_sep_title = optarg; break;

case "sep-reset-after"_fnv1a16:
if (OPTIONAL_ARGUMENT_IS_PRESENT)
config.sep_reset_after = std::stoi(optarg);
else
config.sep_reset_after = true;
break;

default:
return false;
}
Expand Down

0 comments on commit 59cb489

Please sign in to comment.