- Timestamp:
- Aug 5, 2017, 5:54:22 PM (7 years ago)
- Branches:
- master
- Children:
- 268c7e8, e9f3e38, 6deb32b
- Parents:
- 81e93c3
- git-author:
- David Benjamin <davidben@mit.edu> (02/25/13 18:27:35)
- git-committer:
- Jason Gross <jasongross9@gmail.com> (08/05/17 17:54:22)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/lib/BarnOwl/Complete/Client.pm
rbf21c4e r1f92f39 146 146 sub complete_set { 147 147 my $ctx = shift; 148 my $is_unset = ($ctx->words->[0] eq "unset"); 149 150 # Shift away the -q if seen. 151 my $seen_q = 0; 152 if ($ctx->word > 1 && $ctx->words->[1] eq "-q") { 153 $seen_q = 1; 154 $ctx = $ctx->shift_words(1); 155 } 156 157 # First argument is the variable. 148 158 if ($ctx->word == 1) { 149 return ("-q", complete_variable()); 150 } 151 if ($ctx->word == 2 && $ctx->words->[1] eq "-q") { 152 return complete_variable(); 159 my @vars = complete_variable(); 160 if ($is_unset) { 161 # Only complete the variables which are unsettable. 162 @vars = grep { BarnOwl::get_variable_info($_)->{takes_on_off} } @vars; 163 } 164 unshift(@vars, "-q") unless $seen_q; 165 return @vars; 166 } 167 # For set, second argument is the value. 168 if (!$is_unset && $ctx->word == 2) { 169 # Parse what we can out of validsettings. 170 my $info; 171 eval { $info = BarnOwl::get_variable_info($ctx->words->[1]) }; 172 return if $@; 173 if ($info->{validsettings} eq "<path>") { 174 return complete_file($ctx->words->[2]); 175 } elsif ($info->{validsettings} !~ /^<.*>$/) { 176 # Assume it's a comma-separated list of values; 177 return split(",", $info->{validsettings}); 178 } 153 179 } 154 180 return; 155 }156 sub complete_set_args {157 my $ctx = shift;158 my $arg = shift;159 return if $arg;160 return complete_variable();161 181 } 162 182
Note: See TracChangeset
for help on using the changeset viewer.