Class: YardGhurt::App
- Inherits:
-
Object
- Object
- YardGhurt::App
- Defined in:
- lib/yard_ghurt.rb
Overview
A simple CLI app used in file bin/yard_ghurt
.
Mainly for getting GitHub/YARDoc anchor link IDs.
Instance Attribute Summary collapse
- #args ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(args = ARGV) ⇒ App
constructor
A new instance of App.
- #run ⇒ Object
Constructor Details
#initialize(args = ARGV) ⇒ App
Returns a new instance of App.
34 35 36 37 38 |
# File 'lib/yard_ghurt.rb', line 34 def initialize(args = ARGV) super() @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
32 33 34 |
# File 'lib/yard_ghurt.rb', line 32 def args @args end |
Instance Method Details
#run ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/yard_ghurt.rb', line 40 def run parser = OptionParser.new do |op| op.program_name = 'yard_ghurt' op.version = VERSION op. = "Usage: #{op.program_name} [options]" op.on('-a','--anchor <string>','Print GitHub & YARDoc anchor link IDs of <string>') do |str| al = AnchorLinks.new puts "GitHub: #{al.to_github_anchor_id(str)}" puts "YARDoc: #{al.to_yard_anchor_id(str)}" exit end op.on('-g','--github <string>','Print GitHub anchor link ID of <string>') do |str| al = AnchorLinks.new puts al.to_github_anchor_id(str) exit end op.on('-y','--yard <string>','Print YARDoc anchor link ID of <string>') do |str| al = AnchorLinks.new puts al.to_yard_anchor_id(str) exit end op.separator("#{op.summary_indent}---") op.on_tail('-h','--help','Show help') do puts op exit end op.on_tail('-v','--version','Show version') do puts "#{op.program_name} v#{op.version}" exit end end parser.parse!(@args) puts parser # Print help if nothing was parsed. end |