agen 0.2.1 → 0.3
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 +4 -4
- data/.github/workflows/main.yml +3 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +8 -8
- data/lib/agen.rb +4 -0
- data/lib/agen/base_options.rb +36 -0
- data/lib/agen/bash_options.rb +8 -0
- data/lib/agen/cli.rb +11 -0
- data/lib/agen/finder.rb +2 -1
- data/lib/agen/runner.rb +2 -2
- data/lib/agen/shell.rb +45 -0
- data/lib/agen/version.rb +1 -1
- data/lib/agen/zsh_options.rb +8 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edd821d0314f78d537a2228181e4f1dfd0ecaceddc8d8a67bb783499911e7ccb
|
4
|
+
data.tar.gz: 721e0d0871630027ac23c0e08d7dd54e3e20ef26fda674fe755ebb02e0e4be48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2c802aa56ab03338dbe58638a5ab5cf525c13ffef6b0a6b11e5aff39b430d4645f3116d6d49e37425df1704029148ca8df3d8d5dc4af84d0b3dff8ff8263d1c
|
7
|
+
data.tar.gz: d02a95bbee062a61ebe93160c03f773706e45264b09cd4cae9a2aab2c1a45c97078192b399466854e22e87d80266c6aa29e61167ce3f8b726b4a07180311a450
|
data/.github/workflows/main.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,9 @@
|
|
4
4
|
|
5
5
|
Generate shell aliases based on your most commonly entered commands.
|
6
6
|
|
7
|
+
https://user-images.githubusercontent.com/22665228/116796045-5e5a8280-aa8e-11eb-8b4c-4408a252c143.mov
|
8
|
+
|
9
|
+
|
7
10
|
## Installation & Usage
|
8
11
|
|
9
12
|
Install with `gem install agen` and then run `agen` to build your aliases. Then
|
@@ -14,10 +17,11 @@ available options.
|
|
14
17
|
Usage: agen [options]
|
15
18
|
-n, --number=NUMBER Number of aliases to generate
|
16
19
|
-a, --auto Aliases will be generated and applied automatically
|
20
|
+
-r, --rcfile=RCFILE Path to shell rc file
|
21
|
+
-h, --histfile=HISTFILE Path to shell history file
|
17
22
|
```
|
18
23
|
|
19
|
-
Right now, this will only work with `zsh`, but
|
20
|
-
the very lengthy todo list. By default, agen reads from `.zsh_history` and
|
24
|
+
Right now, this will only work with `zsh` or `bash`, but you can specify unique shell config files using the `-r` and `-h` options (though there is no guarantee that your history file will be read properly). By default, agen reads from `.zsh_history` and
|
21
25
|
writes to `.zshrc`.
|
22
26
|
|
23
27
|
## Development
|
@@ -32,14 +36,10 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Jonath
|
|
32
36
|
|
33
37
|
## Roadmap
|
34
38
|
|
35
|
-
* CLI will support any (or most common) shells, and will find history and rc
|
36
|
-
file dynamically.
|
37
|
-
* CLI will let you specific which history file to read from, and which file to output aliases to.
|
38
|
-
* CLI will let you interactively modify proposed aliases.
|
39
39
|
* CLI will let you "ignore" commands you don't want to alias, forever.
|
40
|
+
* CLI will raise user friendly errors if you specify shell configuration files that don't exist.
|
40
41
|
* CLI will let you specify "meta" vs "full" commands.
|
41
|
-
- Full command would be `git checkout branch-name`, meta command would be
|
42
|
-
`git checkout`.
|
42
|
+
- Full command would be `git checkout branch-name`, meta command would be `git checkout`.
|
43
43
|
|
44
44
|
## License
|
45
45
|
|
data/lib/agen.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "agen/version"
|
4
|
+
require_relative "agen/base_options"
|
5
|
+
require_relative "agen/bash_options"
|
6
|
+
require_relative "agen/zsh_options"
|
7
|
+
require_relative "agen/shell"
|
4
8
|
require_relative "agen/cli"
|
5
9
|
require_relative "agen/builder"
|
6
10
|
require_relative "agen/finder"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Agen
|
4
|
+
class BaseOptions
|
5
|
+
def initialize(options)
|
6
|
+
@options = options
|
7
|
+
end
|
8
|
+
|
9
|
+
def set_histfile
|
10
|
+
# handle not set here
|
11
|
+
if !defined?(self.class::HISTFILE)
|
12
|
+
puts "Please specify shell history file with -h option. See agen --help."
|
13
|
+
return false
|
14
|
+
end
|
15
|
+
|
16
|
+
options.tap do |opts|
|
17
|
+
opts[:histfile] = self.class::HISTFILE
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_rcfile
|
22
|
+
if !defined?(self.class::RCFILE)
|
23
|
+
puts "Please specify shell rc file with -r option. See agen --help."
|
24
|
+
return false
|
25
|
+
end
|
26
|
+
|
27
|
+
options.tap do |opts|
|
28
|
+
opts[:rcfile] = self.class::RCFILE
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_reader :options
|
35
|
+
end
|
36
|
+
end
|
data/lib/agen/cli.rb
CHANGED
@@ -21,8 +21,19 @@ module Agen
|
|
21
21
|
opts.on("-a", "--auto", "Aliases will be generated and applied automatically") do |a|
|
22
22
|
options[:auto] = a
|
23
23
|
end
|
24
|
+
|
25
|
+
opts.on("-rRCFILE", "--rcfile=RCFILE", String, "Path to shell rc file") do |r|
|
26
|
+
options[:rcfile] = r
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("-hHISTFILE", "--histfile=HISTFILE", String, "Path to shell history file") do |h|
|
30
|
+
options[:histfile] = h
|
31
|
+
end
|
24
32
|
end.parse!
|
25
33
|
|
34
|
+
options = Shell.new(options).add_options
|
35
|
+
return unless options
|
36
|
+
|
26
37
|
Runner.new(**options).run
|
27
38
|
end
|
28
39
|
end
|
data/lib/agen/finder.rb
CHANGED
data/lib/agen/runner.rb
CHANGED
data/lib/agen/shell.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Agen
|
4
|
+
class Shell
|
5
|
+
def initialize(options)
|
6
|
+
@options = options
|
7
|
+
end
|
8
|
+
|
9
|
+
def add_options
|
10
|
+
if !@options[:histfile]
|
11
|
+
@options = opts_klass.set_histfile
|
12
|
+
end
|
13
|
+
|
14
|
+
if @options && !@options[:rcfile]
|
15
|
+
@options = opts_klass.set_rcfile
|
16
|
+
end
|
17
|
+
|
18
|
+
@options
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def bash?
|
24
|
+
@_bash ||= shell.match?(/bash/)
|
25
|
+
end
|
26
|
+
|
27
|
+
def opts_klass
|
28
|
+
@_opts_klass ||= if bash?
|
29
|
+
BashOptions
|
30
|
+
elsif zsh?
|
31
|
+
ZshOptions
|
32
|
+
else
|
33
|
+
BaseOptions
|
34
|
+
end.new(@options)
|
35
|
+
end
|
36
|
+
|
37
|
+
def shell
|
38
|
+
@_shell ||= ENV["SHELL"]
|
39
|
+
end
|
40
|
+
|
41
|
+
def zsh?
|
42
|
+
@_zsh ||= shell.match?(/zsh/)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
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.3'
|
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-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -75,11 +75,15 @@ files:
|
|
75
75
|
- bin/setup
|
76
76
|
- exe/agen
|
77
77
|
- lib/agen.rb
|
78
|
+
- lib/agen/base_options.rb
|
79
|
+
- lib/agen/bash_options.rb
|
78
80
|
- lib/agen/builder.rb
|
79
81
|
- lib/agen/cli.rb
|
80
82
|
- lib/agen/finder.rb
|
81
83
|
- lib/agen/runner.rb
|
84
|
+
- lib/agen/shell.rb
|
82
85
|
- lib/agen/version.rb
|
86
|
+
- lib/agen/zsh_options.rb
|
83
87
|
homepage: https://github.com/JonathanWThom/agen
|
84
88
|
licenses:
|
85
89
|
- MIT
|