agen 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +9 -7
- data/exe/agen +2 -0
- data/lib/agen/cli.rb +4 -0
- data/lib/agen/runner.rb +35 -3
- data/lib/agen/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 774809f0ab3f7e1b8bab9f9209f71f2e616f5da62edf2bf74f8f47f15d82b5ad
|
4
|
+
data.tar.gz: 20e8af719cc7093968b107a32d98963febb0b03e1c9dddda3a111e1170cded9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66e2e642b09fc276d27ad922f219be8431c2dc2014726227189c1d2a2cb28960a061cb2da11d45fddc9dce5ff292bb70136b71fd8ebd0ca36f9f015385048686
|
7
|
+
data.tar.gz: 1b6beea0fb2a953cd710dc02974ce50aa1198234807cc776e1a5dfd0010dad241f9dbc160c89456b455749381601d9e5d0e03ab198997590068e48cec650cdae
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -7,8 +7,14 @@ Generate shell aliases based on your most commonly entered commands.
|
|
7
7
|
## Installation & Usage
|
8
8
|
|
9
9
|
Install with `gem install agen` and then run `agen` to build your aliases. Then
|
10
|
-
be sure to `source ~/.zshrc` before using the new aliases. Use `agen -h` to see
|
11
|
-
available options.
|
10
|
+
be sure to `source ~/.zshrc` before using the new aliases. Use `agen -h` to see
|
11
|
+
available options.
|
12
|
+
|
13
|
+
```
|
14
|
+
Usage: agen [options]
|
15
|
+
-n, --number=NUMBER Number of aliases to generate
|
16
|
+
-a, --auto Aliases will be generated and applied automatically
|
17
|
+
```
|
12
18
|
|
13
19
|
Right now, this will only work with `zsh`, but support for other shells is on
|
14
20
|
the very lengthy todo list. By default, agen reads from `.zsh_history` and
|
@@ -26,13 +32,9 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Jonath
|
|
26
32
|
|
27
33
|
## Roadmap
|
28
34
|
|
29
|
-
* CLI will let you see proposed aliases and accept/decline them interactively.
|
30
|
-
OR, in "auto mode", commands will be added automatically (as in 1). Auto
|
31
|
-
should be default?
|
32
|
-
* CLI should have helpful output for `-h/--help`.
|
33
35
|
* CLI will support any (or most common) shells, and will find history and rc
|
34
36
|
file dynamically.
|
35
|
-
* CLI will let you specific which history file to read
|
37
|
+
* CLI will let you specific which history file to read from, and which file to output aliases to.
|
36
38
|
* CLI will let you interactively modify proposed aliases.
|
37
39
|
* CLI will let you "ignore" commands you don't want to alias, forever.
|
38
40
|
* CLI will let you specify "meta" vs "full" commands.
|
data/exe/agen
CHANGED
data/lib/agen/cli.rb
CHANGED
@@ -17,6 +17,10 @@ module Agen
|
|
17
17
|
opts.on("-nNUMBER", "--number=NUMBER", Integer, "Number of aliases to generate") do |n|
|
18
18
|
options[:number] = n
|
19
19
|
end
|
20
|
+
|
21
|
+
opts.on("-a", "--auto", "Aliases will be generated and applied automatically") do |a|
|
22
|
+
options[:auto] = a
|
23
|
+
end
|
20
24
|
end.parse!
|
21
25
|
|
22
26
|
Runner.new(**options).run
|
data/lib/agen/runner.rb
CHANGED
@@ -8,10 +8,16 @@ module Agen
|
|
8
8
|
|
9
9
|
attr_reader :histfile, :rcfile
|
10
10
|
|
11
|
-
def initialize(
|
11
|
+
def initialize(
|
12
|
+
histfile: DEFAULT_HISTFILE,
|
13
|
+
rcfile: DEFAULT_RCFILE,
|
14
|
+
number: DEFAULT_NUMBER,
|
15
|
+
auto: false
|
16
|
+
)
|
12
17
|
@histfile = histfile
|
13
18
|
@rcfile = rcfile
|
14
19
|
@number = number
|
20
|
+
@auto = auto
|
15
21
|
end
|
16
22
|
|
17
23
|
def run
|
@@ -21,10 +27,36 @@ module Agen
|
|
21
27
|
File.open(rcfile, "a") do |file|
|
22
28
|
puts "Writing new aliases to #{rcfile}:"
|
23
29
|
aliases.each do |al|
|
24
|
-
|
25
|
-
|
30
|
+
if auto
|
31
|
+
write_auto(file, al)
|
32
|
+
else
|
33
|
+
write_interactive(file, al)
|
34
|
+
end
|
26
35
|
end
|
27
36
|
end
|
28
37
|
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
attr_reader :auto
|
42
|
+
|
43
|
+
def write_auto(file, aliaz)
|
44
|
+
puts aliaz
|
45
|
+
file.puts(aliaz)
|
46
|
+
end
|
47
|
+
|
48
|
+
def write_interactive(file, aliaz)
|
49
|
+
puts "Proposed alias: #{aliaz}"
|
50
|
+
print "Accept? [n to reject, any other key to accept]: "
|
51
|
+
response = gets.chomp
|
52
|
+
if response != "n"
|
53
|
+
file.puts(aliaz)
|
54
|
+
puts "Alias written"
|
55
|
+
else
|
56
|
+
puts "Alias skipped"
|
57
|
+
end
|
58
|
+
|
59
|
+
puts
|
60
|
+
end
|
29
61
|
end
|
30
62
|
end
|
data/lib/agen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Thom
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|