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

Conversation

Projects
None yet
5 participants
@Hunsu
Contributor

Hunsu commented Jul 20, 2016

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

Show outdated Hide outdated share/completions/arc.fish
# fish completion for arc
function __fish_arc_needs_command
set cmd (commandline -opc)

This comment has been minimized.

@siteshwar

siteshwar Jul 21, 2016

Member

It should be a local variable :

set -l cmd (commandline -opc)
@siteshwar

siteshwar Jul 21, 2016

Member

It should be a local variable :

set -l cmd (commandline -opc)

This comment has been minimized.

@Hunsu

Hunsu Jul 21, 2016

Contributor

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

@Hunsu

Hunsu Jul 21, 2016

Contributor

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

Show outdated Hide outdated share/completions/arc.fish
end
function __fish_arc_using_command
set cmd (commandline -opc)

This comment has been minimized.

@siteshwar

siteshwar Jul 21, 2016

Member

Declare as local variable.

@siteshwar

siteshwar Jul 21, 2016

Member

Declare as local variable.

This comment has been minimized.

@Hunsu

Hunsu Jul 21, 2016

Contributor

Done.

@Hunsu

Hunsu Jul 21, 2016

Contributor

Done.

Show outdated Hide outdated share/completions/arc.fish
function __fish_arc_needs_command
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 -a $cmd[1] = 'arc' ]

This comment has been minimized.

@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.

@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

Show outdated Hide outdated share/completions/arc.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

This comment has been minimized.

@faho

faho Aug 2, 2016

Member

skip_next is never set to 0 and hence effectively unused.

Please remove it.

@faho

faho Aug 2, 2016

Member

skip_next is never set to 0 and hence effectively unused.

Please remove it.

Show outdated Hide outdated share/completions/arc.fish
function __fish_arc_needs_command
set cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]

This comment has been minimized.

@faho

faho Aug 2, 2016

Member

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

@faho

faho Aug 2, 2016

Member

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

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Aug 2, 2016

Member

Those were my last two nitpicks, I think.

Sorry for the delay.

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Aug 3, 2016

Member

Merged, thanks!

Member

faho commented Aug 3, 2016

Merged, thanks!

@krader1961 krader1961 modified the milestones: fish 2.4.0, next-2.x Sep 3, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment