Add completions for Arcanist #3256

Merged
merged 1 commit into from Aug 3, 2016

Projects

None yet

5 participants

@Hunsu
Contributor
Hunsu commented Jul 20, 2016 edited

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

@siteshwar siteshwar and 1 other commented on an outdated diff Jul 21, 2016
share/completions/arc.fish
@@ -0,0 +1,294 @@
+# fish completion for arc
+
+function __fish_arc_needs_command
+ set cmd (commandline -opc)
@siteshwar
siteshwar Jul 21, 2016 Member

It should be a local variable :

set -l cmd (commandline -opc)
@Hunsu
Hunsu Jul 21, 2016 Contributor

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

@siteshwar siteshwar and 1 other commented on an outdated diff Jul 21, 2016
share/completions/arc.fish
@@ -0,0 +1,294 @@
+# fish completion for arc
+
+function __fish_arc_needs_command
+ set cmd (commandline -opc)
+ if [ (count $cmd) -eq 1 -a $cmd[1] = 'arc' ]
+ return 0
+ end
+ return 1
+end
+
+function __fish_arc_using_command
+ set cmd (commandline -opc)
@siteshwar
siteshwar Jul 21, 2016 Member

Declare as local variable.

@Hunsu
Hunsu Jul 21, 2016 Contributor

Done.

@faho faho commented on an outdated diff Jul 21, 2016
share/completions/arc.fish
@@ -0,0 +1,294 @@
+# fish completion for arc
+
+function __fish_arc_needs_command
+ set -l cmd (commandline -opc)
+ if [ (count $cmd) -eq 1 -a $cmd[1] = 'arc' ]
@faho
faho Jul 21, 2016 edited 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
@faho faho commented on an outdated diff Aug 2, 2016
share/completions/arc.fish
@@ -0,0 +1,309 @@
+# fish completion for arc
+
+function __fish_arc_needs_command
+ set cmd (commandline -opc)
+ if [ (count $cmd) -eq 1 ]
+ return 0
+ else
+ 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
@faho
faho Aug 2, 2016 Member

skip_next is never set to 0 and hence effectively unused.

Please remove it.

@faho faho commented on an outdated diff Aug 2, 2016
share/completions/arc.fish
@@ -0,0 +1,309 @@
+# fish completion for arc
+
+function __fish_arc_needs_command
+ set cmd (commandline -opc)
+ if [ (count $cmd) -eq 1 ]
@faho
faho Aug 2, 2016 Member

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

@faho
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
Member
faho commented Aug 3, 2016

Merged, thanks!

@krader1961 krader1961 modified the milestone: 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