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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88c5c183242fa63c57940eba901e982778e930921fdaf8eda8ba2c64a23801f0
4
- data.tar.gz: 262a494cd57ad6d3ee4474eee51a686a94309084222b5fc4b128be7ce35e5f40
3
+ metadata.gz: 774809f0ab3f7e1b8bab9f9209f71f2e616f5da62edf2bf74f8f47f15d82b5ad
4
+ data.tar.gz: 20e8af719cc7093968b107a32d98963febb0b03e1c9dddda3a111e1170cded9a
5
5
  SHA512:
6
- metadata.gz: d994611c28f6f086450a4baf40e842cff15108cedaeba542710827ec77499f41086bcc1f334866873c1f3ef167588885ede145de26afb60eb30f6644036ba0ca
7
- data.tar.gz: d553d15e0420538459819547d86faa117244833080ad27dc35177d776a2e37a2996c047042acdd0aa5d426da02df1060e0413f9cc5c09590b24a9b3a50804f52
6
+ metadata.gz: 66e2e642b09fc276d27ad922f219be8431c2dc2014726227189c1d2a2cb28960a061cb2da11d45fddc9dce5ff292bb70136b71fd8ebd0ca36f9f015385048686
7
+ data.tar.gz: 1b6beea0fb2a953cd710dc02974ce50aa1198234807cc776e1a5dfd0010dad241f9dbc160c89456b455749381601d9e5d0e03ab198997590068e48cec650cdae
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Released]
2
2
 
3
+ ## [0.2.0] - 2021-04-30
4
+ - Fix: Ensures the same aliases is not built for multiple commands in the same run.
5
+
3
6
  ## [0.1.7] - 2021-04-26
4
7
  - Fix: Ensures the same aliases is not built for multiple commands in the same run.
5
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- agen (0.1.7)
4
+ agen (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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 form, and which file to output aliases to.
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
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $LOAD_PATH.unshift("#{__dir__}/../lib")
4
+
3
5
  require "agen"
4
6
 
5
7
  Agen::CLI.new(ARGV).run
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(histfile: DEFAULT_HISTFILE, rcfile: DEFAULT_RCFILE, number: DEFAULT_NUMBER)
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
- puts al
25
- file.puts(al)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Agen
4
- VERSION = "0.1.7"
4
+ VERSION = "0.2.0"
5
5
  end
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.1.7
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-04-27 00:00:00.000000000 Z
11
+ date: 2021-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake