Skip to content

Implement command arguments #36

Closed
Closed

Description

@altsem

Build support for passing flags to commands (for example git push --force-with-lease, or P-fp in Magit).

  • Iterate on the Submenu ui layout of Gitu. Where do command flags fit in?
  • Some arguments are enabled per default.

image

Activity

  1. frank-lenormand commented on Mar 13, 2024

    @frank-lenormand

    Given v0.6.2, I would recommend the following:

    1. Allow all lettered core commands to be called with the alt modifier.

    2. Display all available optional flags in a new window, similar to the screenshot in the body of this issue:

      • If all available options have a single-letter flag (I think that’s the case), then hitting the associated key should enable that option.
        For example: -f/--force for git push would be used upon hitting the f key.

      • Otherwise, an arbitrary letter that doesn’t collide with the others on screen could be highlighted and used as trigger, similarly to how btop does it:

    3. If an option requires an argument, a prompt could be displayed (in the case of an arbitrary value) or another window (in the case of a fixed set of choices).

    Example:

    # Run Gitu
    $ gitu
    
    # Push the branch with argument
    alt-p
    
    # Select the force flag in the upcoming window
    f
    
    # Gitu runs `git push --force`
    

    HTH!

  2. altsem commented on Mar 13, 2024

    @altsem
    OwnerAuthor

    I appreciate the input, think that most people would expect magit-like bindings out of gitu. I'm unfamiliar with btop, perhaps there's a way to design it configurable.

    I know alt can be problematic for mac terminal users with non-us layouts.

    Perhaps if the dash was included in the bindings table -f (for --force-with-lease).

    You'd just have to copy the default keymap and change:
    -f -> f
    etc.
    p -> alt-p

    Externalizing keymap configuration becomes a whole other issue it feels like though.

  3. mattgallagher92 commented on Mar 19, 2024

    @mattgallagher92

    I'm excited to see so much activity on this library! I use Magit with vi-style keybindings and would love to have a similar experience outside of Emacs.

    Just wanted to note that this issue is the main blocker stopping me (so maybe others too?) from switching to gitu - I fairly regularly amend commits or interactively rebase branches that I've pushed, hence often force-with-lease-push too.

  4. frank-lenormand commented on Mar 20, 2024

    @frank-lenormand

    I realised that the functionality needs to assume that multiple flags might need to be toggled, which the single-modifier proposal doesn’t solve.

    Alternatively, here’s a way that e.g. Kitty (and some Vim-type bindings for the browser I can’t remember, whenever jumping to a hyperlink) uses:

    1. In the menu that shows all possible flags to be passed to the underlying command, a special keyboard mapping is hit.
      Example: shift+ctrl+e

    2. Single letters (or combinations of successive letters, to avoid collisions) are highlighted on screen. They must be already visible prior to hitting the combination above, or be generated and inserted dynamically into view.
      Examples (brackets = highlighted):

       - `-[f] force push`
       - `[f]orce push`
       - `[0] force push`
       - `[f]orce [p]ush`
       - [00] force push`
      
    3. The use hits the highlighted letters/combinations associated with the flags to select.

      1. a. If any parameters are required, they are prompted for.
      2. b. If optional parameters are possible, hitting the validation key (enter) and leaving the prompt empty does not pass any value to the optional flag.
    4. Selected flags (or their associated letter) should be shown somewhere on the view.
      Example: Selected flags: -f

    HTH.

    Externalizing keymap configuration becomes a whole other issue it feels like though.

    Yes, and a ton of work too! If you don’t particularly want to tackle this now, I reckon it’s best to focusing on finding good defaults, first.

  5. pinned this issue on Mar 23, 2024
  6. added 2 commits that reference this issue on Mar 27, 2024
    3df673b
    009647a
  7. altsem commented on Mar 27, 2024

    @altsem
    OwnerAuthor

    Got something working for a starter.
    It only supports true/false flags, and it only introduces --force-with-lease so far. Should be easy to add more boolean flags now.

  8. Repository owner locked and limited conversation to collaborators on Mar 28, 2024
  9. converted this issue into a discussion #101 on Mar 28, 2024
  10. unpinned this issue on Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions