Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small refactor of 'else if' statements in hyprctl #6585

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Yaraslaut
Copy link

Describe your PR, what does it fix/add?

Small refactor of else if statements inside hyperctl

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

Also, some of the outputs of hyperctl does not have new lines in the end, namely all calls to log function, if you are interested i can refactor it for a bit and introduce usage of std::println

Is it ready for merging, or does it need work?

ready

@Yaraslaut Yaraslaut changed the title Small refactor of 'else if' statements in hyperctl Small refactor of 'else if' statements in hyprctl Jun 18, 2024
{"/decorations", 1}
};
for (const auto& [cmd, minArgs] : commands) {
if(fullRequest.contains(cmd))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, this might bug out if the rest of the request has the thing. Maybe substring only the part after the first / and before the first space?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that i do not change any behavior of parsing in this pr.
for safer way of handling cli option i would go directly with something like https://github.com/contour-terminal/contour/blob/121d7ade938ac99a18ff0b4f650254778baddafd/src/contour/ContourApp.cpp#L297
and then just

_syntax = parameterDefinition();
optional<CLI::flag_store> flagsOpt = CLI::parse(_syntax.value(), argc, argv);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you didn't but when already changing it why not improve?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my feeling is that this is not a good place for input validation, especially inside for loop during check for the flags

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not input validation - it's making sure you choose the right value in case of e.g.

/notify blah blah /decorations

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If /notify blah blah /decorations is not ill-formed then logic is not right, since only /notify command will be handled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, the /decorations is a part of the parameter. Notify for example takes a string, so the user can put whatever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants