Class: Flatter::CLI

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

Instance Method Summary collapse

Instance Method Details

#startObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/xcflatter/cli.rb', line 7

def start
    options = {}
    OptionParser.new do |opts|
    opts.banner = "Usage: flatter PATH_TO_XCODEPROJ [options]"

    opts.on("-g String", String, "Path to root group") do |group_path|
        options[:group_path] = group_path
    end

    options[:files_ext] = ".swift"
    opts.on("-e String", String, "File extension. Default: .swift") do |files_ext|
        prefix = files_ext.start_with?(".") ? "" : "."
        options[:files_ext] = prefix + files_ext
    end
    end.parse!

    if ARGV.any?
        project_path = ARGV.first
        dest_file_ext = options[:files_ext]
        root_group_path = options[:group_path]
        Flatter::FileMover.new.move_all_files_with_ext_to_root_group(project_path, dest_file_ext, root_group_path)
    else
        puts "🛑 Error: Not arguments passed"
    end
end