Method: Fast::Cli#option_parser

Defined in:
lib/fast/cli.rb

#option_parserObject

rubocop:disable Metrics/MethodLength, Metrics/AbcSize



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/fast/cli.rb', line 99

def option_parser # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
  @option_parser ||= OptionParser.new do |opts| # rubocop:disable Metrics/BlockLength
    opts.banner = 'Usage: fast expression <files> [options]'
    opts.on('-d', '--debug', 'Debug fast engine') do
      @debug = true
    end

    opts.on('--ast', 'Print AST instead of code') do
      @show_sexp = true
    end

    opts.on('--link', 'Print link to repository URL') do
      require 'fast/git'
      @show_link = true
    end

    opts.on('--permalink', 'Print permalink to repository URL') do
      require 'fast/git'
      @show_permalink = true
    end

    opts.on('-p', '--parallel', 'Paralelize search') do
      @parallel = true
    end

    opts.on("--sql", "Use SQL instead of Ruby") do
      @sql = true
    end

    opts.on('--captures', 'Print only captures of the patterns and skip node results') do
      @captures = true
    end

    opts.on('--headless', 'Print results without the file name in the header') do
      @headless = true
    end

    opts.on('--bodyless', 'Print results without the code details') do
      @bodyless = true
    end

    opts.on('--pry', 'Jump into a pry session with results') do
      @pry = true
      require 'pry'
    end

    opts.on('-s', '--similar', 'Search for similar code.') do
      @similar = true
    end

    opts.on('--no-color', 'Disable color output') do
      @colorize = false
    end

    opts.on('--from-code', 'From code') do
      @from_code = true
    end

    opts.on_tail('--version', 'Show version') do
      puts Fast::VERSION
      exit
    end

    opts.on_tail('-h', '--help', 'Show help. More at https://jonatas.github.io/fast') do
      @help = true
    end
  end
end