Class: Genfrag::App::Command
- Inherits:
-
Object
- Object
- Genfrag::App::Command
- Defined in:
- lib/genfrag/app/command.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#ops ⇒ Object
an OpenStruct of the options.
-
#options ⇒ Object
a Hash used by optparse.
Instance Method Summary collapse
-
#cli_p(cli = true, str = '') ⇒ Object
Print running output when used in command-line mode.
- #cli_run(args) ⇒ Object
-
#clierr_p(str) ⇒ Object
Print an error from the command-line options.
-
#initialize(out = STDOUT, err = STDERR) ⇒ Command
constructor
A new instance of Command.
- #run(args) ⇒ Object
-
#standard_options ⇒ Object
Define the command-line option available.
Constructor Details
#initialize(out = STDOUT, err = STDERR) ⇒ Command
Returns a new instance of Command.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/genfrag/app/command.rb', line 10 def initialize( out = STDOUT, err = STDERR ) @out = out @err = err @options = { # :skeleton_dir => File.join(mrbones_dir, 'data'), # :with_tasks => false, # :verbose => false, # :name => nil, # :output_dir => nil } @ops = OpenStruct.new #@options[:skeleton_dir] = ::Bones.path('data') unless test(?d, skeleton_dir) end |
Instance Attribute Details
#ops ⇒ Object
an OpenStruct of the options
8 9 10 |
# File 'lib/genfrag/app/command.rb', line 8 def ops @ops end |
#options ⇒ Object
a Hash used by optparse
7 8 9 |
# File 'lib/genfrag/app/command.rb', line 7 def @options end |
Instance Method Details
#cli_p(cli = true, str = '') ⇒ Object
Print running output when used in command-line mode
34 35 36 37 |
# File 'lib/genfrag/app/command.rb', line 34 def cli_p(cli=true, str='') return false if !cli or @ops.quiet @out.puts str end |
#cli_run(args) ⇒ Object
24 25 26 |
# File 'lib/genfrag/app/command.rb', line 24 def cli_run( args ) raise NotImplementedError end |
#clierr_p(str) ⇒ Object
Print an error from the command-line options
41 42 43 44 45 46 |
# File 'lib/genfrag/app/command.rb', line 41 def clierr_p(str) @out.puts @err.puts "Error: #{str}" @out.puts @out.puts opt_parser end |
#run(args) ⇒ Object
28 29 30 |
# File 'lib/genfrag/app/command.rb', line 28 def run( args ) raise NotImplementedError end |
#standard_options ⇒ Object
Define the command-line option available
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 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 |
# File 'lib/genfrag/app/command.rb', line 50 def { :verbose => ['-v', '--verbose', 'enable verbose output', lambda { |ruby19bug| [:verbose] = true }], :tracktime => ['-m', '--tracktime', 'track execution time', lambda { |ruby19bug| [:tracktime] = true }], :quiet => ['-q', '--quiet', 'silence output', lambda { |ruby19bug| [:quiet] = true }], :indir => ['-i', '--in DIR', String, 'input directory', "(default #{Dir.pwd})", lambda{ |value| [:indir] = value }], :outdir => ['-o', '--out DIR', String, 'output directory', "(default #{Dir.pwd})", lambda{ |value| [:outdir] = value }], :re5 => ['-5', '--re5 ENZYME', String, "5' restriction enzyme", lambda { |value| [:re5] = value }], :re3 => ['-3', '--re3 ENZYME', String, "3' restriction enzyme", lambda { |value| [:re3] = value }], :sqlite => ['-t', '--sqlite', 'use sqlite', '(default is tab-delimited)', lambda { |ruby19bug| [:sqlite] = true }], :filelookup => ['-l', '--lookup FILE', String, "name of the frequency lookup file generated by 'index'", lambda { |value| [:filelookup] = value }], :filefasta => ['-f', '--fasta FILE', String, 'name of the Fasta sequences file', lambda { |value| [:filefasta] = value }], :seqsize => ['-s', '--seqsize SIZE', Array, '', lambda { |value| [:seqsize] = value }], :adapter5 => ['-y', '--adapter5 ADAPTER', String, '', lambda { |value| [:adapter5] = value }], :adapter3 => ['-z', '--adapter3 ADAPTER', String, '', lambda { |value| [:adapter3] = value }], :named_adapter5 => ['-b', '--named-adapter5 NAME', String, '', lambda { |value| [:named_adapter5] = value }], :named_adapter3 => ['-c', '--named-adapter3 NAME', String, '', lambda { |value| [:named_adapter3] = value }], :adapter5_size => ['-d', '--adapter5-size SIZE', Integer, '', lambda { |value| [:adapter5_size] = value }], :adapter3_size => ['-e', '--adapter3-size SIZE', Integer, '', lambda { |value| [:adapter3_size] = value }], :adapter5_sequence => ['-w', '--adapter5-sequence SEQUENCE', String, '', lambda { |value| [:adapter5_sequence] = value }], :adapter3_sequence => ['-x', '--adapter3-sequence SEQUENCE', String, '', lambda { |value| [:adapter3_sequence] = value }], :fileadapters => ['-a', '--adapters FILE', String, '', lambda { |value| [:fileadapters] = value }] } end |