You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/clamp/completer`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
# Clamp::Completer
4
5
5
-
TODO: Delete this and the text above, and describe your gem
6
+
Automatically generate shell auto-completion scripts for Ruby command-line tools built using the [clamp](https://github.com/mdub/clamp)gem.
6
7
7
8
## Installation
8
9
@@ -12,23 +13,85 @@ Add this line to your application's Gemfile:
12
13
gem 'clamp-completer'
13
14
```
14
15
15
-
And then execute:
16
-
17
-
$ bundle
18
-
19
16
Or install it yourself as:
20
17
21
-
$ gem install clamp-completer
18
+
```
19
+
$ gem install clamp-completer
20
+
```
22
21
23
22
## Usage
24
23
25
-
TODO: Write usage instructions here
24
+
Require the `clamp/completer` and in your application's root command, add a subcommand:
Currently, subcommand completions and flag-type options defined through `option '--debug', :flag, 'enable debug'` should work correctly out-of-the-box. For options that take parameters,
53
+
such as file paths or a predefined set of words, you can define methods on your command classes that will be used to determine how the values should be completed:
defcomplete_yaml_file# name derived from the YAML_FILE argument description
60
+
{ glob:'*.yml' }
61
+
end
62
+
end
63
+
```
64
+
65
+
```ruby
66
+
Clampdo
67
+
option '--role', 'ROLE_NAME', "node role"
68
+
69
+
defcomplete_role# name derived from the attribute name
70
+
"master worker"# will add "master" and "worker" as completion responses when you do: your_app --role <tab>
71
+
end
72
+
end
73
+
```
74
+
75
+
#### Completion method response types
76
+
77
+
##### String
78
+
79
+
A space separated string of possible values for the option
80
+
81
+
##### Symbol
82
+
83
+
Currently known symbols:
84
+
85
+
*`:dirs` will complete directory names
86
+
*`:files` will complete file names
87
+
*`:hosts` will complete known host names
26
88
27
-
##Development
89
+
##### Hash
28
90
29
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec`to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
91
+
Much like the Symbols, but returned in Hash format to enable passing options:
30
92
31
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
93
+
*`{ glob: '*.yml' }` will complete files endinging with `.yml`
94
+
*`{ command: 'cut -d':' -f1 /etc/passwd' }` will run a command to get completion candidates, in this case the usernames from `/etc/password`
0 commit comments