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

fix(options): handling and overwriting cli opts #859

Merged
merged 2 commits into from
Nov 11, 2021

Conversation

a-kenji
Copy link
Contributor

@a-kenji a-kenji commented Nov 10, 2021

  • previously it was only possible to turn off certain features with a
    command line option, now it is possible to also overwrite this
    behavior in a sane way, for that some breaking changes happened:

    following options got renamed and inverted:

    disable_mouse_mode -> mouse_mode
    no_pane_frames -> pane_frames
    

    following cli options got added:

    mouse-mode [bool]
    pane-frames [bool]
    simplified-ui [bool]
    

    the following cli flag got removed:

    simplified-ui
    

    They can be specified in the following way:

    zellij options --mouse-mode true
    

    in order to enable the mouse mode, even if it is turned off in the
    config file:

    mouse_mode: false
    

    The order is now as follows:

    1. corresponding flag (disable-mouse-mode)
    2. corresponding option (mouse-mode)
    3. corresponding config option (mouse_mode)

* previously it was only possible to turn off certain features with a
  command line option, now it is possible to also overwrite this
  behavior in a sane way, for that some breaking changes happened:

  following options got renamed and inverted:
  ```
  disable_mouse_mode -> mouse_mode
  no_pane_frames -> pane_frames
  ```

  following cli options got added:
  ```
  mouse-mode [bool]
  pane-frames [bool]
  simplified-ui [bool]
  ```

  the following cli flag got removed:
  ```
  simplified-ui
  ```

  They can be specified in the following way:
  ```
  zellij options --mouse-mode true
  ```
  in order to enable the mouse mode, even if it is turned off in the
  config file:
  ```
  mouse_mode: false
  ```

  The order is now as follows:
  1. corresponding flag (`disable-mouse-mode`)
  2. corresponding option (`mouse-mode`)
  3. corresponding config option (`mouse_mode`)
@a-kenji a-kenji changed the title fix(options): handling ond verwriting cli opts fix(options): handling and overwriting cli opts Nov 10, 2021
@jovandeginste
Copy link

The last part is a bit confusing me. I think what you are saying, is:

--mouse-mode true --no-mouse-mode: mouse mode is disabled

Correct? Even when the flags are reversed in order?

Flags should always have precedence over configuration files, so that's good! In case of multiple flags controlling the same behavior (or repeated flags), the expected behavior is less predictable, but usually "last flag wins". Is such a thing doable without a large refactor? Alternatively, an error is also acceptable... (Conflicting flags)

As a side note, is it possible to make true implicit (but allowed as explicit value)?

By this, i mean that --mouse-mode=true, --mouse-mode true and --mouse-mode are all valid and do the exact same thing, enable mouse mode.

Respectively, you can also use: --mouse-mode=false, --mouse-mode false and --no-mouse-mode to disable mouse mode.

@jovandeginste
Copy link

Oh, and to be clear: I have zero experience in rust; every time I look at rust code, my head starts spinning 😁

Just saying, I'm basing my reply on your text, not your code. If you want a once-over of your code, someone else should really do it...

@a-kenji
Copy link
Contributor Author

a-kenji commented Nov 11, 2021

@jovandeginste
Thanks for the input,
and no worries I just wanted to hear what you had to say about the behavior!

--mouse-mode true --no-mouse-mode: mouse mode is disabled

Correct? Even when the flags are reversed in order?

Yes, that is correct.

In case of multiple flags controlling the same behavior (or repeated flags), the expected behavior is less predictable, but usually "last flag wins". Is such a thing doable without a large refactor?

Yes, that is possible,
currently not without a huge change to how we parse the cli options.
We are waiting on this front for a new version of a library that is still in a beta
version currently - once we move over it should be a single option we specify.

Similar goes for the implicit action.

Alternatively, an error is also acceptable... (Conflicting flags)

I think that is reasonable, thanks!

* example:
  ```
  zellij options --mouse-mode true --disable-mouse-mode`
  ```
  ```
  $ error: The argument '--mouse-mode <mouse-mode>' cannot be used with '--disable-mouse-mode'
  ```
@jovandeginste
Copy link

Good luck 🤞

@a-kenji a-kenji merged commit bd8c834 into zellij-org:main Nov 11, 2021
@a-kenji a-kenji deleted the fix-boolean-options branch May 10, 2022 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants