Skip to content

Commit

Permalink
Update in anticipation of a new version of Getopt::Complete.
Browse files Browse the repository at this point in the history
The new version implements a function that uses a different environment
variable as part of avoiding evaluating output redirection in completion.

For now, encountering the old Getopt::Complete setup will quietly return
no completions.
  • Loading branch information
tmooney committed Aug 18, 2011
1 parent 1b79f7b commit 6c8a5e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion bin/ur
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ use strict;
use warnings;

BEGIN {
if ($ENV{COMP_LINE}) {
if ($ENV{COMP_CWORD}) {
eval "use Getopt::Complete::Cache class => 'UR::Namespace::Command', above => 1;";
exit if ($@);
}
if ($ENV{COMP_LINE}) {
#for transitioning from older version of completion
#just return no result
exit;
}
};

use above "UR";
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Dispatch/Shell.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sub execute_with_shell_params_and_exit {
$Command::entry_point_class ||= $class;
$Command::entry_point_bin ||= File::Basename::basename($0);

if ($ENV{COMP_LINE}) {
if ($ENV{COMP_CWORD}) {
require Getopt::Complete;
my @spec = $class->resolve_option_completion_spec();
my $options = Getopt::Complete::Options->new(@spec);
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/V1.pm
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ My::Command->execute_with_shell_params_and_exit;
$Command::entry_point_class ||= $class;
$Command::entry_point_bin ||= File::Basename::basename($0);

if ($ENV{COMP_LINE}) {
if ($ENV{COMP_CWORD}) {
require Getopt::Complete;
my @spec = $class->resolve_option_completion_spec();
my $options = Getopt::Complete::Options->new(@spec);
Expand Down

0 comments on commit 6c8a5e6

Please sign in to comment.