Class: Audition::CLI
- Inherits:
-
Object
- Object
- Audition::CLI
- Defined in:
- lib/audition/cli.rb
Constant Summary collapse
- USAGE =
"usage: audition [options] TARGET [FILE...] " \ "(a .rb script, directory, config.ru dir, Rails root, " \ "gem dir, installed gem name, or several .rb files)"
Class Method Summary collapse
-
.run(argv, stdout: $stdout, stderr: $stderr) ⇒ Integer
Entry point used by
exe/audition.
Instance Method Summary collapse
-
#initialize(stdout:, stderr:) ⇒ CLI
constructor
A new instance of CLI.
- #run(argv) ⇒ Object
Constructor Details
#initialize(stdout:, stderr:) ⇒ CLI
Returns a new instance of CLI.
24 25 26 27 |
# File 'lib/audition/cli.rb', line 24 def initialize(stdout:, stderr:) @stdout = stdout @stderr = stderr end |
Class Method Details
.run(argv, stdout: $stdout, stderr: $stderr) ⇒ Integer
Entry point used by exe/audition.
20 21 22 |
# File 'lib/audition/cli.rb', line 20 def self.run(argv, stdout: $stdout, stderr: $stderr) new(stdout: stdout, stderr: stderr).run(argv) end |
Instance Method Details
#run(argv) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/audition/cli.rb', line 29 def run(argv) = parse(argv.dup) return if .is_a?(Integer) return print_capabilities() if [:capabilities] args = [:args] if args.empty? @stderr.puts(style(, io: @stderr).dim(USAGE)) return 2 end # A single argument keeps full detection (including the # dynamic probe); several arguments are the git-hook shape, # a plain list of staged .rb files audited statically. target = if args.size == 1 Target.detect(args.first) else Target.for_files(args) end target = deps_target(target) if [:deps] if target.type == :bundle sweep(target, ) else audit(target, ) end rescue Error => e complain(e., ) 2 end |