[i3ass][i3fyra][i3viswiz] i3viswiz accepts any amount of arguments as long as the last one starts with u|l|d|r|up|left|down|right #194

Closed
opened 2023-07-20 13:41:18 +00:00 by 1ntronaut · 2 comments
1ntronaut commented 2023-07-20 13:41:18 +00:00 (Migrated from github.com)

Description

    1. I found out that i3viswiz does accept some (I suppose) non-intended input. It seems i3viswiz will accept any amount of arguments, as long as the last argument is any of u|l|d|r|up|left|down|right.

To Reproduce
Steps to reproduce the behavior:

  • see terminal commands and output below:

as intended, direction only:

~ > i3viswiz --verbose l
m [con_mark=i3viswiz-last-direction=94457275819920] mark --toggle --add i3viswiz-last-direction=94457275819920
m [con_id=94457275831344] mark --add i3viswiz-last-direction=94457275819920
m [con_id=94457275960096] focus
[{"success":true},{"success":true},{"success":true}]

single extra argument before direction:

~ > i3viswiz --verbose asdfasdf l  
m [con_mark=i3viswiz-last-direction=94457275819920] mark --toggle --add i3viswiz-last-direction=94457275819920
m [con_id=94457275831344] mark --add i3viswiz-last-direction=94457275819920
m [con_id=94457275960096] focus
[{"success":true},{"success":true},{"success":true}]

multiple extra arguments before direction:

~ > i3viswiz --verbose asdfasdf qwer asdfgasdf l
m [con_mark=i3viswiz-last-direction=94457275819920] mark --toggle --add i3viswiz-last-direction=94457275819920
m [con_id=94457275831344] mark --add i3viswiz-last-direction=94457275819920
m [con_id=94457275960096] focus
[{"success":true},{"success":true},{"success":true}]

multiple extra arguments, direction inbetween:

~ > i3viswiz --verbose blah bar left nei
[ERROR] nei not valid direction (l|r|u|d)

multiple extra arguments, last one starting with direction:

~ > i3viswiz --verbose blah bar rleftnei 
m [con_mark=i3viswiz-last-direction=94457276140256] mark --toggle --add i3viswiz-last-direction=94457276140256
m [con_id=94457275831344] mark --add i3viswiz-last-direction=94457275819920
m [con_id=94457275960096] focus
[{"success":true},{"success":true},{"success":true}]

Directionality doesn't matter here, i3viswiz chooses whatever valid argument it finds first, so i3viswiz blah barnei lright will focus to the left.

Expected behavior
I was expecting an error message on multiple arguments and/or all arguments starting with u|l|d|r|up|left|down|right

Desktop (please complete the following information):

  • Arch btw
~ > i3 --version
i3 version 4.22 (2023-01-02) © 2009 Michael Stapelberg and contributors
**Description** - 2) I found out that i3viswiz does accept some (I suppose) non-intended input. It seems i3viswiz will accept any amount of arguments, as long as the last argument is any of `u|l|d|r|up|left|down|right`. **To Reproduce** Steps to reproduce the behavior: - see terminal commands and output below: as intended, direction only: ```bash ~ > i3viswiz --verbose l m [con_mark=i3viswiz-last-direction=94457275819920] mark --toggle --add i3viswiz-last-direction=94457275819920 m [con_id=94457275831344] mark --add i3viswiz-last-direction=94457275819920 m [con_id=94457275960096] focus [{"success":true},{"success":true},{"success":true}] ``` single extra argument before direction: ```bash ~ > i3viswiz --verbose asdfasdf l m [con_mark=i3viswiz-last-direction=94457275819920] mark --toggle --add i3viswiz-last-direction=94457275819920 m [con_id=94457275831344] mark --add i3viswiz-last-direction=94457275819920 m [con_id=94457275960096] focus [{"success":true},{"success":true},{"success":true}] ``` multiple extra arguments before direction: ```bash ~ > i3viswiz --verbose asdfasdf qwer asdfgasdf l m [con_mark=i3viswiz-last-direction=94457275819920] mark --toggle --add i3viswiz-last-direction=94457275819920 m [con_id=94457275831344] mark --add i3viswiz-last-direction=94457275819920 m [con_id=94457275960096] focus [{"success":true},{"success":true},{"success":true}] ``` multiple extra arguments, direction inbetween: ```bash ~ > i3viswiz --verbose blah bar left nei [ERROR] nei not valid direction (l|r|u|d) ``` multiple extra arguments, last one starting with direction: ```bash ~ > i3viswiz --verbose blah bar rleftnei m [con_mark=i3viswiz-last-direction=94457276140256] mark --toggle --add i3viswiz-last-direction=94457276140256 m [con_id=94457275831344] mark --add i3viswiz-last-direction=94457275819920 m [con_id=94457275960096] focus [{"success":true},{"success":true},{"success":true}] ``` Directionality doesn't matter here, i3viswiz chooses whatever valid argument it finds first, so `i3viswiz blah barnei lright` will focus to the left. **Expected behavior** I was expecting an error message on multiple arguments and/or all arguments starting with `u|l|d|r|up|left|down|right` **Desktop (please complete the following information):** - Arch btw ```bash ~ > i3 --version i3 version 4.22 (2023-01-02) © 2009 Michael Stapelberg and contributors ```
budRich commented 2023-07-22 12:35:33 +00:00 (Migrated from github.com)

This is more or less the same problem as with i3Kornhe (#195) . I don't remember why i went with this approach of just getting the first character of the last argument, if it was just a way to support subcommands like this, or if it was fast or if i was stupid.

i3viswiz (focusing) is however not as sensitive as i3Kornhe (moving), since it is unlikely that users hold down the directions keybindings for more than one or two step (where i3Kornhe it is quite likely ~100 steps will be triggered). So here i feel more comfortable adding similar checks as the PR #196 proposes.

This is more or less the same problem as with i3Kornhe (#195) . I don't remember why i went with this approach of just getting the first character of the last argument, if it was just a way to support subcommands like this, or if it was **fast** or if i was stupid. i3viswiz (focusing) is however not as sensitive as i3Kornhe (moving), since it is unlikely that users hold down the directions keybindings for more than one or two step (where i3Kornhe it is quite likely ~100 steps will be triggered). So here i feel more comfortable adding similar checks as the PR #196 proposes.
budRich commented 2023-07-22 13:06:02 +00:00 (Migrated from github.com)

Yeah, this was smoother than #196 , i will merge #197 . Below is new error messages:

$ i3viswiz --verbose asdfasdf l  
[ERROR] i3viswiz: direction ('asdfasdf') is not valid! ( left|right|up|down|l|r|u|d )

$ i3viswiz --verbose asdfasdf qwer asdfgasdf l
[ERROR] i3viswiz: direction ('asdfasdf') is not valid! ( left|right|up|down|l|r|u|d )

$ i3viswiz --verbose blah bar left nei
[ERROR] i3viswiz: direction ('blah') is not valid! ( left|right|up|down|l|r|u|d )

$ i3viswiz --verbose left right up
[ERROR] i3viswiz: expected 0 arguments got '(right up)'

Yeah, this was smoother than #196 , i will merge #197 . Below is new error messages: ``` $ i3viswiz --verbose asdfasdf l [ERROR] i3viswiz: direction ('asdfasdf') is not valid! ( left|right|up|down|l|r|u|d ) $ i3viswiz --verbose asdfasdf qwer asdfgasdf l [ERROR] i3viswiz: direction ('asdfasdf') is not valid! ( left|right|up|down|l|r|u|d ) $ i3viswiz --verbose blah bar left nei [ERROR] i3viswiz: direction ('blah') is not valid! ( left|right|up|down|l|r|u|d ) $ i3viswiz --verbose left right up [ERROR] i3viswiz: expected 0 arguments got '(right up)' ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bud/i3ass#194
No description provided.