Class: Hank::CLI

Inherits:
Thor
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/hank/cli.rb

Overview

Command line interface for Hank

Instance Method Summary collapse

Instance Method Details

#editObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/hank/cli.rb', line 24

def edit
  hankfile_path = Pathname.new(Dir.pwd).join('Hankfile')

  unless hankfile_path.exist?
    puts "No Hankfile found in current directory. Run 'hank' to create one.".red
    exit 1
  end

  hankfile = Hankfile.from_file(hankfile_path)
  file_selector = FileSelector.new(hankfile.mappings.keys)
  selected_files = file_selector.run

  if selected_files
    hankfile.update_mappings(selected_files)
    puts 'Hankfile updated with selected files.'
  else
    puts 'Edit cancelled.'
  end
end

#indexObject



11
12
13
14
15
16
17
18
19
# File 'lib/hank/cli.rb', line 11

def index
  hankfile_path = Pathname.new(Dir.pwd).join('Hankfile')

  if hankfile_path.exist?
    process_existing_hankfile(hankfile_path)
  else
    create_new_hankfile(hankfile_path)
  end
end

#versionObject



47
48
49
# File 'lib/hank/cli.rb', line 47

def version
  puts "Hank version #{Hank::VERSION}"
end