zquestz / s

Open a web search in your terminal.
MIT License
2.32k stars 114 forks source link

Fish completion #91

Closed ajm188 closed 8 years ago

ajm188 commented 8 years ago

Full completion support, as per discussion in #90. (will rebase and squash after "+1")

Copying in @bucaran, for any potential feedback.

zquestz commented 8 years ago

This looks reasonable to me. Would need to cleanup the commits. =)

ajm188 commented 8 years ago

@zquestz cleaned up :)

ghost commented 8 years ago

Looks very complete (pun intended). @ajm188 :smile:

ajm188 commented 8 years ago

Thanks! If people open issues related to this, feel free to cc me

zquestz commented 8 years ago

Awesome stuff. Thanks so much for the contribution!

zquestz commented 8 years ago

Finding issues in the latest code. Here is what I am seeing.

quest@alucard ~/g/s/g/z/s> s -p facebook -cv 
-cb  (binary to launch search URI)  -cl            (list supported providers)  -cs         (launch web server)
-ck      (path to key.pem for TLS)  -cp  (search provider (default "google"))  -cv  (display URL when opening)

If you tab after doing a 1 letter flag, it lists incorrect options.

zquestz commented 8 years ago

Also error messages are pretty horrendous.

quest@alucard ~/g/s/g/z/s> s -p -c contains: Unknown option “-c”
~/.config/fish/completions/s.fish (line 8):             if not contains $cmd[-1] (s -l)
                                                           ^
in function “__fish_s_needs_option_argument”
    called on standard input
    with parameter list “-p”

in command substitution
    called on standard input

       contains -- test if a word is present in a list

   Synopsis
       contains [OPTIONS] KEY [VALUES...]

contains: Type “help contains” for related documentation

8tracks          cplusplus    google           macports   quora           twitter     
500px            crunchyroll  googleplus       Makefile   README.md       unity3d     
amazon           digg         hackernews       mdn        reddit          upcloud     
arstechnica      diigo        ietf             msdn       rottentomatoes  vimeo   
ghost commented 8 years ago

There may be a few bugs here, but you can start fixing this by calling contains in the following way:

contains -- needle array

Notice the --. If you don't write the --, contains will assume that arguments starting with a dash are option flags and will incorrectly try to parse them.