Syntax Tree ships with the ‘stree` CLI
, which can be used to inspect and manipulate Ruby code. This module is responsible for powering that CLI
.
The help message displayed if the input arguments are not correctly ordered or formatted.
def run(argv) name, *arguments = argv config_file = ConfigFile.new arguments.unshift(*config_file.arguments) options = Options.new options.parse(arguments) action = case name when "a", "ast" AST.new(options) when "c", "check" Check.new(options) when "ctags" CTags.new(options) when "debug" Debug.new(options) when "doc" Doc.new(options) when "e", "expr" Expr.new(options) when "f", "format" Format.new(options) when "help" puts HELP return 0 when "j", "json" Json.new(options) when "lsp" LanguageServer.new( print_width: options.print_width, ignore_files: options.ignore_files ).run return 0 when "m", "match" Match.new(options) when "s", "search" Search.new(arguments.shift) when "version" puts SyntaxTree::VERSION return 0 when "w", "write" Write.new(options) else warn(HELP) return 1 end queue = Queue.new if arguments.any? || options.scripts.any? arguments.each do |pattern| Dir .glob(pattern) .each do |filepath| next unless File.readable?(filepath) next if options.ignore_files.any? { File.fnmatch(_1, filepath) } queue << FileItem.new(filepath) end end options.scripts.each do |script| queue << ScriptItem.new(script, options.extension) end else queue << STDINItem.new(options.extension) end if process_queue(queue, action) action.failure 1 else action.success 0 end end
Run the CLI
over the given array of strings that make up the arguments passed to the invocation.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4