atli 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c562004e1672d0f99daf0e7bf492dc6073218383
4
- data.tar.gz: 2dea03764c0b2be0d546fb86eec81a5f3490fc0d
3
+ metadata.gz: 58210dece21bb6f5e41acd1ad1ace1230b856687
4
+ data.tar.gz: 600873fc0d393528eeca7ecac5ad9359a2b88af6
5
5
  SHA512:
6
- metadata.gz: 6506ade3b0c291a74baf77958c3d1e757f4d806ade22098d3d51cce08490d3498dfdd0b5d639c77c6f14018e04fbe96db97fab8a6274724d9c433f215e5c786a
7
- data.tar.gz: e2740e6af60505b0ec9a76300b51b15405d13eecfe63c4817aac37e81b6ae9061b6ab5ccc6b4f625505e411719ff6492c0c1198fc35eb70083a3ff351eb7b1cd
6
+ metadata.gz: 641a5a3c2283c1c70e68b71291bfebb1e118bba9bf3c0678aaffcd74606c604dd052aa6ff79b393cfdea606a4a8312013d629a04039a1dd9db9d8c93b5855f9a
7
+ data.tar.gz: 7c21174463863a9463dcfb1bb945c76866cbc3576c85a7b5c9d6389ec56a255117b196fccf75e449d705aee84e00076bdd5887427ec220d97596609dbb645e37
@@ -9,7 +9,17 @@ Gem::Specification.new do |spec|
9
9
  spec.description = "Atli is a fork of Thor that's better or worse."
10
10
  spec.email = "neil@atli.nrser.com"
11
11
  spec.executables = %w(thor)
12
- spec.files = %w(.yardopts atli.gemspec) + Dir["*.md", "bin/*", "lib/**/*.rb"]
12
+
13
+ spec.files = [
14
+ '.yardopts',
15
+ 'atli.gemspec',
16
+ 'support/completion/complete.inc.bash.erb',
17
+ ] + Dir[
18
+ "*.md",
19
+ "bin/*",
20
+ "lib/**/*.rb",
21
+ ]
22
+
13
23
  spec.homepage = "https://github.com/nrser/atli"
14
24
  spec.licenses = %w(MIT)
15
25
  spec.name = "atli"
@@ -14,7 +14,7 @@ class Thor
14
14
  #
15
15
  # @return [String]
16
16
  #
17
- VERSION = '0.1.11'
17
+ VERSION = '0.1.12'
18
18
 
19
19
 
20
20
  # The version of Thor that Atli is up to date with.
@@ -27,7 +27,7 @@ class Thor
27
27
  #
28
28
  # @return [String]
29
29
  #
30
- THOR_VERSION = '0.1.11'
30
+ THOR_VERSION = '0.1.12'
31
31
 
32
32
 
33
33
  # Are we running from the source code (vesus from a Gem install)?
@@ -0,0 +1,159 @@
1
+ ##
2
+ # Bash completion adapter for `locd`
3
+ #
4
+ # `source` me!
5
+ #
6
+ # @note
7
+ # I had through about trying to use $BASHPID to perhaps keep state on a
8
+ # completion server of some type, but it changes with every invocation...
9
+ # would need to reach the parent process' PID somehow, assuming that's even
10
+ # how completion works.
11
+ #
12
+ # @note
13
+ # It looks like `complete` (the Bash builtin that facilitates completion)
14
+ # can take a command to execute instead of a function.
15
+ #
16
+ # Since we're going to have to shell-out in some way, that might be better
17
+ # so we can write the logic in Ruby (or at least not bash). Assuming it
18
+ # sets the completion ENV vars and you work from there, so we would lose
19
+ # the `_init_completion` functionality from `bash-completion` (v2).
20
+ #
21
+ ##
22
+
23
+ # Functions
24
+ # ============================================================================
25
+
26
+ # Append a message to $LOCD_BASH_COMP_DEBUG_FILE if the var is not empty.
27
+ #
28
+ __<%= name %>_debug() {
29
+ if [[ -n ${LOCD_BASH_COMP_DEBUG_FILE} ]]; then
30
+ echo "$*" >> "${LOCD_BASH_COMP_DEBUG_FILE}"
31
+ fi
32
+ }
33
+
34
+
35
+ # Entry point for bash completion.
36
+ #
37
+ __<%= name %>_complete() {
38
+ # Timing is commented out 'cause depends on a ms-resolution bin I built
39
+ # at some point and don't want to figure that out...
40
+ # local start_time="$(ms)"
41
+
42
+ __<%= name %>_debug "${FUNCNAME[0]}: STARTing the show...."
43
+
44
+ local cur prev words cword split
45
+
46
+ _init_completion -s || return
47
+
48
+ __<%= name %>_debug "${FUNCNAME[0]}: initialized" \
49
+ "cur='$cur'" \
50
+ "prev='$prev'" \
51
+ "words='${words[@]}'" \
52
+ "cword='$cword'" \
53
+ "split='${split}'"
54
+
55
+ __<%= name %>_debug "${FUNCNAME[0]}: Getting respond from app bin at ${words[0]}"
56
+
57
+ local response="$(${words[0]} bash-complete complete -- "$cur" "$prev" "${cword}" "${split}" "${words[@]}")"
58
+
59
+ # We need to figure out if we're about to complete a `--flag=` word, in
60
+ # which case we want to turn `nospace` on, do the compelte, then
61
+ # turn it back off so we don't add an annoying space after the `=`.
62
+ #
63
+ # We'll need these variables for the logic:
64
+ #
65
+ local nospace
66
+ local response_array=( $response )
67
+ local response_array_length="${#response_array[@]}"
68
+ local response_length="${#response}"
69
+
70
+ __<%= name %>_debug "${FUNCNAME[0]}: Got response;" \
71
+ "response='$response'" \
72
+ "response_length='${response_length}'" \
73
+ "response_array='${response[@]}'" \
74
+ "response_array_length='${response_array_length}'"
75
+
76
+ # We're going to flip `nospace` off if ALL of:
77
+ #
78
+ # 1. There is only one "word" element in the response.
79
+ #
80
+ # 2. The response length (in characters) is greater than zero
81
+ # (this might be redundant, was here before (1)).
82
+ #
83
+ # 3. The last character of the single word is `=`.
84
+ #
85
+ # If all of those are true, then `nospace` var should be set to "true".
86
+ #
87
+ # This probably isn't the most bullet-proof logic, but it's a start...
88
+ #
89
+ if (( response_array_length == 1 && response_length > 0 )); then
90
+ local index=$response_length
91
+ ((index--))
92
+ local last_char="${response:$index:1}"
93
+ [ $last_char == "=" ] && nospace=true
94
+ fi
95
+
96
+ # If we indeed set `nospace` then flip `nospace` off
97
+ if [[ -n "$nospace" ]]; then
98
+ compopt +o nospace
99
+ fi
100
+
101
+ COMPREPLY=( $(compgen -W "$response" -- "$cur" ) )
102
+
103
+ # If we had turned `nospace` off, turn it back on
104
+ if [[ -n "$nospace" ]]; then
105
+ compopt -o nospace
106
+ unset nospace
107
+ fi
108
+
109
+ # See comment up top about `ms` bin...
110
+ # local end_time="$(ms)"
111
+ # local delta_s="$((end_time-start_time))"
112
+ # __<%= name %>_debug "${FUNCNAME[0]}: We're DONE here ($delta_s ms)."
113
+
114
+ __<%= name %>_debug "${FUNCNAME[0]}: We're DONE here."
115
+ __<%= name %>_debug
116
+
117
+ return 0
118
+ }
119
+
120
+
121
+ # Binding
122
+ # ============================================================================
123
+
124
+ # Hook in the `__locd_debug` function to `complete`
125
+ #
126
+ # @see https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html
127
+ #
128
+ if [[ $(type -t compopt) = "builtin" ]]; then
129
+ # -o default (option `default`)
130
+ # Use Readline’s default filename completion if the compspec generates
131
+ # no matches.
132
+ #
133
+ # -F __locd_complete
134
+ # Tell `complete` to execute the `__locd_complete` function in the current
135
+ # shell environemnt.
136
+ #
137
+ complete -o default -F __<%= name %>_complete <%= bin %>
138
+ # complete -o default -C 'locd complete-cmd' locd
139
+ else
140
+ # UNTESTED! `compopt` is builtin for me.
141
+ #
142
+ # -o default (option `default`)
143
+ # Use Readline’s default filename completion if the compspec generates
144
+ # no matches.
145
+ #
146
+ # -o nospace (option `nospace`)
147
+ # "Tell Readline not to append a space (the default) to words completed at
148
+ # the end of the line." (via docs, see above).
149
+ #
150
+ # Not sure why this is here, guessing if `compopt` is *not* a `builtin`
151
+ # then maybe that detects and older version? My `bash@4.4.23` has
152
+ # `compopt` as a `builtin`, so have not taken this branch.
153
+ #
154
+ # -F __locd_complete
155
+ # Tell `complete` to execute the `__locd_complete` function in the current
156
+ # shell environemnt.
157
+ #
158
+ complete -o default -o nospace -F __<%= name %>_complete <%= bin %>
159
+ fi
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Souza (Atli)
@@ -141,6 +141,7 @@ files:
141
141
  - lib/thor/shell/html.rb
142
142
  - lib/thor/util.rb
143
143
  - lib/thor/version.rb
144
+ - support/completion/complete.inc.bash.erb
144
145
  homepage: https://github.com/nrser/atli
145
146
  licenses:
146
147
  - MIT