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

Add completions for Arcanist #3256

Merged
merged 1 commit into from Aug 3, 2016
Merged

Add completions for Arcanist #3256

merged 1 commit into from Aug 3, 2016

Conversation

@Hunsu
Copy link
Contributor

Hunsu commented Jul 20, 2016

Add completions for Arcanist, the tool used to interact with Phabricator instance.

# fish completion for arc

function __fish_arc_needs_command
set cmd (commandline -opc)

This comment has been minimized.

Copy link
@siteshwar

siteshwar Jul 21, 2016

Member

It should be a local variable :

set -l cmd (commandline -opc)

This comment has been minimized.

Copy link
@Hunsu

Hunsu Jul 21, 2016

Author Contributor

Done. I really don't know what that line does. I just copied it from git.fish.

end

function __fish_arc_using_command
set cmd (commandline -opc)

This comment has been minimized.

Copy link
@siteshwar

siteshwar Jul 21, 2016

Member

Declare as local variable.

This comment has been minimized.

Copy link
@Hunsu

Hunsu Jul 21, 2016

Author Contributor

Done.

@Hunsu Hunsu force-pushed the Hunsu:arc-complete branch 2 times, most recently from 19321d5 to 4df7edd Jul 21, 2016

function __fish_arc_needs_command
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 -a $cmd[1] = 'arc' ]

This comment has been minimized.

Copy link
@faho

faho Jul 21, 2016

Member

You really don't want this idiom. We removed it from the codebase (IIRC entirely) for a reason. This will break when you alias arc (because of the $cmd[1] = 'arc', when you do something; and arc or similar and when you enter an option before a command (which arc might or might not support).

What you want is, depending on how arc works, do something like

for token in $cmd
    switch $token
        case '-*'
            continue
        case '*'
            return 1
     end
     return 0

This will assume the first non-option is a command.

If you want to be more precise (because e.g. arc can take arguments to options before the command), take a look at the new git.fish.

@floam floam added the completions label Jul 23, 2016
@Hunsu Hunsu force-pushed the Hunsu:arc-complete branch from 4df7edd to 9d9d69d Jul 26, 2016
set -l skip_next 1
# Skip first word because it's "arc" or a wrapper
for c in $cmd[2..-1]
test $skip_next -eq 0

This comment has been minimized.

Copy link
@faho

faho Aug 2, 2016

Member

skip_next is never set to 0 and hence effectively unused.

Please remove it.


function __fish_arc_needs_command
set cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]

This comment has been minimized.

Copy link
@faho

faho Aug 2, 2016

Member

if not set -q cmd[2] works and is a bit more concise.

@faho
Copy link
Member

faho commented Aug 2, 2016

Those were my last two nitpicks, I think.

Sorry for the delay.

@Hunsu Hunsu force-pushed the Hunsu:arc-complete branch from 9d9d69d to 267125b Aug 2, 2016
@floam floam added this to the next-2.x milestone Aug 3, 2016
@faho faho merged commit b1f576d into fish-shell:master Aug 3, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@faho
Copy link
Member

faho commented Aug 3, 2016

Merged, thanks!

@krader1961 krader1961 modified the milestones: fish 2.4.0, next-2.x Sep 3, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.