Class: Poepod::Cli

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

Overview

Command-line interface for Poepod

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/poepod/cli.rb', line 58

def self.exit_on_failure?
  true
end

.shared_optionsObject

Define shared options



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

def self.shared_options
  option :exclude, type: :array, default: nil,
                   desc: "List of patterns to exclude"
  option :config, type: :string, desc: "Path to configuration file"
  option :include_binary, type: :boolean, default: false, desc: "Include binary files (encoded in MIME format)"
  option :include_dot_files, type: :boolean, default: false, desc: "Include dot files"
  option :output_file, type: :string, desc: "Output path"
  option :base_dir, type: :string, desc: "Base directory for relative file paths in output"
end

Instance Method Details

#concat(*files) ⇒ Object



25
26
27
28
29
30
# File 'lib/poepod/cli.rb', line 25

def concat(*files)
  check_files(files)
  output_file = determine_output_file(files)
  base_dir = options[:base_dir] || Dir.pwd
  process_files(files, output_file, base_dir)
end

#wrap(gemspec_path) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/poepod/cli.rb', line 37

def wrap(gemspec_path)
  base_dir = options[:base_dir] || File.dirname(gemspec_path)
  output_file = options[:output_file] || File.join(base_dir, "#{File.basename(gemspec_path, ".*")}_wrapped.txt")
  processor = Poepod::GemProcessor.new(
    gemspec_path,
    include_unstaged: options[:include_unstaged],
    exclude: options[:exclude],
    include_binary: options[:include_binary],
    include_dot_files: options[:include_dot_files],
    base_dir: base_dir,
    config_file: options[:config],
  )
  success, result, unstaged_files = processor.process(output_file)
  if success
    handle_wrap_result(success, result, unstaged_files)
  else
    puts result
    exit(1)
  end
end