Class: Agen::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/agen/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = []) ⇒ CLI

Returns a new instance of CLI.



7
8
9
# File 'lib/agen/cli.rb', line 7

def initialize(args = [])
  @args = args
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/agen/cli.rb', line 11

def run
  options = {}

  OptionParser.new do |opts|
    opts.banner = "Usage: agen [options]"

    opts.on("-v", "--version", String, "Version") do |v|
      puts Agen::VERSION
      return false
    end

    opts.on("-nNUMBER", "--number=NUMBER", Integer, "Number of aliases to generate") do |n|
      options[:number] = n
    end

    opts.on("-a", "--auto", "Aliases will be generated and applied automatically") do |a|
      options[:auto] = a
    end

    opts.on("-rRCFILE", "--rcfile=RCFILE", String, "Path to shell rc file") do |r|
      options[:rcfile] = r
    end

    opts.on("-sHISTFILE", "--shell-history=HISTFILE", String, "Path to shell history file") do |s|
      options[:histfile] = s
    end
  end.parse!

  options = Shell.new(options).add_options
  return unless options

  Runner.new(**options).run
end