zyedidia / eget

Easily install prebuilt binaries from GitHub.
MIT License
954 stars 39 forks source link

cli argument flag processing disregarding flag values #16

Closed vladdoster closed 2 years ago

vladdoster commented 2 years ago

Can't grok logic for the returns asset choices

command in question

$ eget --asset=.tar.gz --system=linux/amd64 neovim/neovim

4 candidates found for asset .tar.gz
please select manually:
  (1) nvim-linux64.tar.gz
  (2) nvim-linux64.tar.gz.sha256sum
  (3) nvim-macos.tar.gz
  (4) nvim-macos.tar.gz.sha256sum
Enter selection number:

The above command and subsequently returned choices strikes me to believe that:

  1. This is a bug in the processing of CLI flags that disregards previous flag values and returns results that should have been filtered out.

ex. I specify criteria of .tar.gz assets for Linux, but eget returned darwin assets that don't satisfy criteria.

Happy to fix this, but wanted to get confirmation before doing needful.

  1. Somewhat quirky behavior which I am guilty of glossing over when reading through documentation. If this is the case, could you ELI5 the design choices around parsing CLI arguments and another hypothetical scenario that explains returned asset choices?
vladdoster commented 2 years ago

@zyedidia Any input on this?

zyedidia commented 2 years ago

Currently the asset and system flags do not filter each other, instead the asset option has priority. I will consider ways that this can be fixed.

vladdoster commented 2 years ago

@zyedidia

You could do something simple like...

package main

import (
    "fmt"
    "strings"
)

func main() {
        # uses --system arg
    fmt.Println(strings.Contains("Assume", "sum"))
        # use --asset arg
    fmt.Println(strings.HasSuffix("Hello World", "World"))
}

However, the more straightforward solution would leverage regex.

vladdoster commented 2 years ago

Thank you for the insight. Closing.