Skip to content

Commit bcd598c

Browse files
committed
- Initial version
1 parent b5b2d92 commit bcd598c

File tree

3 files changed

+133
-3
lines changed

3 files changed

+133
-3
lines changed

README.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Completely - Bash Completions Generator
2+
3+
[![Gem Version](https://badge.fury.io/rb/completely.svg)](https://badge.fury.io/rb/completely)
4+
[![Build Status](https://github.com/DannyBen/completely/workflows/Test/badge.svg)](https://github.com/DannyBen/completely/actions?query=workflow%3ATest)
5+
6+
---
7+
8+
Completely is a command line utility and a Ruby library that lets you generate
9+
bash completion scripts from simple YAML configuration.
10+
11+
This tool is for you it:
12+
13+
1. You develop your own command line tools.
14+
2. Your life feels empty without bash completions.
15+
3. Bash completion scripts scare you.
16+
17+
---
18+
19+
20+
## Install
21+
22+
```
23+
$ gem install completely
24+
```
25+
26+
## Usage
27+
28+
The `completely` command line works with a simple YAML configuration file as
29+
input, and generates a bash completions script as output.
30+
31+
The configuration file is built like this:
32+
33+
```yaml
34+
pattern:
35+
- --argument
36+
- --param
37+
- command
38+
```
39+
40+
You can save a sample YAML file by running:
41+
42+
```
43+
$ completely new
44+
```
45+
46+
This will generate a file named `completely.yaml` with this content:
47+
48+
```yaml
49+
mygit:
50+
- --help
51+
- --version
52+
- status
53+
- init
54+
- commit
55+
56+
mygit status:
57+
- --help
58+
- --verbose
59+
- --branch
60+
61+
mygit init:
62+
- --bare
63+
- <directory>
64+
65+
mygit commit:
66+
- <file>
67+
- --help
68+
- --message
69+
- --all
70+
- -a
71+
- --quiet
72+
- -q
73+
```
74+
75+
Each pattern in this configuration file will be checked against the user's
76+
input, and if the input **starts with** a matching pattern, the list that
77+
follows it will be suggested as completions.
78+
79+
To generate the bash script, simply run:
80+
81+
```
82+
$ completely generate
83+
84+
# or, to just preview it without saving:
85+
$ completely preview
86+
```
87+
88+
For more options (like setting input/output path), run
89+
90+
```
91+
$ completely --help
92+
```
93+
94+
### Suggesting files and directories
95+
96+
You may have noticed that the sample file contains two special entries:
97+
98+
- `<file>`
99+
- `<directory>`
100+
101+
These patterns will add the list of files and directories
102+
(when `<file>` is used) or just directories (when `<directory` is used) to
103+
the list of suggestions.
104+
105+
For those interested in the technical details, any word between `<...>` will
106+
simply be added using the [`compgen -A action`][compgen] function, so you can
107+
in fact use any of its supported arguments.
108+
109+
110+
### Using the generated completion scripts
111+
112+
In order to enable the completions, simply source the generated script:
113+
114+
```
115+
$ source completely.bash
116+
```
117+
118+
You may wish to add this to your `~/.bashrc` file to enable this for future
119+
sessions (just be sure to use absolute path).
120+
121+
122+
## Contributing / Support
123+
124+
If you experience any issue, have a question or a suggestion, or if you wish
125+
to contribute, feel free to [open an issue][issues].
126+
127+
---
128+
129+
[issues]: https://github.com/DannyBen/completely/issues
130+
[compgen]: https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html

completely.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ require 'date'
44
require 'completely/version'
55

66
Gem::Specification.new do |s|
7-
s.name = 'bashly'
7+
s.name = 'completely'
88
s.version = Completely::VERSION
99
s.date = Date.today.to_s
10-
s.summary = "Bash Completion Script Generator"
10+
s.summary = "Bash Completions Generator"
1111
s.description = "Generate bash completion scripts using simple YAML configuration"
1212
s.authors = ["Danny Ben Shitrit"]
1313
s.email = 'db@dannyben.com'

lib/completely/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Completely
2-
VERSION = "0.0.0"
2+
VERSION = "0.1.0"
33
end

0 commit comments

Comments
 (0)