Skip to content

Conversation

@Hunsu
Copy link
Contributor

@Hunsu 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be a local variable :

set -l cmd (commandline -opc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

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

@faho faho Jul 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip_next is never set to 0 and hence effectively unused.

Please remove it.

@faho
Copy link
Member

faho commented Aug 2, 2016

Those were my last two nitpicks, I think.

Sorry for the delay.

@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
@faho
Copy link
Member

faho commented Aug 3, 2016

Merged, thanks!

@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

Development

Successfully merging this pull request may close these issues.

5 participants