agen 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcbe6011253c346bb0abe4d9147146610cbc9fc98f7769f31b960ba20304af17
4
- data.tar.gz: 5e8035ec1fb0aec32b660395ea24d6d5a8a88aa9e8cc88d0122115d6a2358150
3
+ metadata.gz: f90fceac9fed45a59113e45eb28e8eef96f7552b487d4ccc90f037765bdd96d3
4
+ data.tar.gz: 60e5528277c8cd195d43e67bf4653d70ddddb9cd93d1109c623e4d5ded9c546f
5
5
  SHA512:
6
- metadata.gz: 4ca5c06be491092c201c8dcbce7623f0a887d4fbd52e36ab9afc27281ced79fbc97ecb878fc016f4c958893e82bd6718cd08f978c2619fc7a8f59bee7e84358a
7
- data.tar.gz: 6e62b98c8745005dd1c1632abdc44adef8b55c9e47cfab0318652248b6e5df125109f378b53ca549c8521b6fa07bb70554397b09bcdb63e6bfdb24342f20e30b
6
+ metadata.gz: 138b4c4c646a0b62b1665c057fa5dd659c13643fe751c2909c281c9f5446ca23ab2c67a8c51dc967ba38fb43ef1b8f4017e7d019337cbe378f27bd2f89b7119b
7
+ data.tar.gz: 43ad014f35c326d08f2c242680eaccd36e55a4bb14c316ab5cf8c6136fa82ed4956c15d3ab88d18670a2403e46f7f57aee103bb9c60ad111e83645e6d253a281
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Released]
2
2
 
3
+ ## [0.1.6] - 2021-04-25
4
+ - Adds ability to specify number of aliases to generate.
5
+
3
6
  ## [0.1.5] - 2021-04-24
4
7
 
5
8
  - Initial release that anyone should reasonably use.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- agen (0.1.5)
4
+ agen (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -6,10 +6,12 @@ Generate shell aliases based on your most commonly entered commands.
6
6
 
7
7
  ## Installation & Usage
8
8
 
9
- Install with `gem install agen` and then run `agen` to build your aliases.
9
+ Install with `gem install agen` and then run `agen` to build your aliases. Use
10
+ `agen -h` to see available options.
10
11
 
11
12
  Right now, this will only work with `zsh`, but support for other shells is on
12
- the very lengthy todo list.
13
+ the very lengthy todo list. By default, agen reads from `.zsh_history` and
14
+ writes to `.zshrc`.
13
15
 
14
16
  ## Development
15
17
 
@@ -23,7 +25,6 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Jonath
23
25
 
24
26
  ## Roadmap
25
27
 
26
- * CLI will let you specify number of aliases you want to create.
27
28
  * CLI will let you see proposed aliases and accept/decline them interactively.
28
29
  OR, in "auto mode", commands will be added automatically (as in 1). Auto
29
30
  should be default?
data/lib/agen/cli.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "optparse"
4
+
3
5
  module Agen
4
6
  class CLI
5
7
  def initialize(args = [])
@@ -7,8 +9,17 @@ module Agen
7
9
  end
8
10
 
9
11
  def run
10
- # TODO: Parse args/options
11
- Runner.new.run
12
+ options = {}
13
+
14
+ OptionParser.new do |opts|
15
+ opts.banner = "Usage: agen [options]"
16
+
17
+ opts.on("-nNUMBER", "--number=NUMBER", Integer, "Number of aliases to generate") do |n|
18
+ options[:number] = n
19
+ end
20
+ end.parse!
21
+
22
+ Runner.new(**options).run
12
23
  end
13
24
  end
14
25
  end
data/lib/agen/runner.rb CHANGED
@@ -4,16 +4,18 @@ module Agen
4
4
  class Runner
5
5
  DEFAULT_HISTFILE = "#{Dir.home}/.zsh_history"
6
6
  DEFAULT_RCFILE = "#{Dir.home}/.zshrc"
7
+ DEFAULT_NUMBER = 5
7
8
 
8
9
  attr_reader :histfile, :rcfile
9
10
 
10
- def initialize(histfile: DEFAULT_HISTFILE, rcfile: DEFAULT_RCFILE)
11
+ def initialize(histfile: DEFAULT_HISTFILE, rcfile: DEFAULT_RCFILE, number: DEFAULT_NUMBER)
11
12
  @histfile = histfile
12
13
  @rcfile = rcfile
14
+ @number = number
13
15
  end
14
16
 
15
17
  def run
16
- commands = Finder.new(histfile).commands
18
+ commands = Finder.new(histfile).commands(limit: @number)
17
19
  aliases = Builder.new(commands, rcfile).aliases
18
20
 
19
21
  File.open(rcfile, "a") do |file|
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.5"
4
+ VERSION = "0.1.6"
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.5
4
+ version: 0.1.6
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-25 00:00:00.000000000 Z
11
+ date: 2021-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake