Class: CycleAnalystLogger::Cli
- Inherits:
-
Object
- Object
- CycleAnalystLogger::Cli
- Includes:
- GLI::App
- Defined in:
- lib/cycle_analyst_logger/cli.rb
Instance Attribute Summary collapse
-
#enable_phaserunner ⇒ Object
readonly
Returns the value of attribute enable_phaserunner.
-
#loop_count ⇒ Object
readonly
Returns the value of attribute loop_count.
-
#pr ⇒ Object
readonly
Returns the value of attribute pr.
-
#quiet ⇒ Object
readonly
Returns the value of attribute quiet.
Instance Method Summary collapse
Instance Attribute Details
#enable_phaserunner ⇒ Object (readonly)
Returns the value of attribute enable_phaserunner.
11 12 13 |
# File 'lib/cycle_analyst_logger/cli.rb', line 11 def enable_phaserunner @enable_phaserunner end |
#loop_count ⇒ Object (readonly)
Returns the value of attribute loop_count.
14 15 16 |
# File 'lib/cycle_analyst_logger/cli.rb', line 14 def loop_count @loop_count end |
#pr ⇒ Object (readonly)
Returns the value of attribute pr.
12 13 14 |
# File 'lib/cycle_analyst_logger/cli.rb', line 12 def pr @pr end |
#quiet ⇒ Object (readonly)
Returns the value of attribute quiet.
13 14 15 |
# File 'lib/cycle_analyst_logger/cli.rb', line 13 def quiet @quiet end |
Instance Method Details
#main ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 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 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 |
# File 'lib/cycle_analyst_logger/cli.rb', line 18 def main program_desc 'Store the streaming data log output of a Grin Cycle Analyst V3 and optionally a Phaserunner' version CycleAnalystLogger::VERSION subcommand_option_handling :normal arguments :strict sort_help :manually desc 'Cycle Analyst Serial (USB) device' default_value '/dev/cycle_analyst' arg 'tty', :optional flag [:t, :tty_ca] desc 'Cycle Analyst Serial port baudrate' default_value 9600 arg 'baudrate', :optional flag [:b, :baud_ca] desc 'Get PhaseRunner Logs also' default_value true switch [:enable_phaserunner] desc 'Phaserunner Serial (USB) device' default_value '/dev/phaserunner' arg 'tty', :optional flag [:tty_pr] desc 'Phaserunner Serial port baudrate' default_value 115200 arg 'baudrate', :optional flag [:baud_pr] desc 'Get Gps Logs also' default_value true switch [:enable_gps] desc 'Gps Serial (USB) device' default_value '/dev/gps' arg 'tty', :optional flag [:tty_gps] desc 'Gps Serial port baudrate' default_value 115200 arg 'baudrate', :optional flag [:baud_gps] desc "How many lines to read" default_value :forever flag [:l, :loop_count] desc 'Do not output to stdout' switch [:q, :quiet] desc 'Log the Cycle Analyst and optionally GPS and Phaserunner to a file' command :log do |log| log.desc 'Disable writing raw nmea to its own file' log.default_value false log.switch [:disable_nmea_out] log.action do |, , args| cycle_analyst = CycleAnalyst.new() cycle_analyst.get_logs(loop_count, quiet, [:disable_nmea_out]) end end desc 'Transform logs to CA format' arg_name 'log_filename' command :to_ca_file do |to_ca_file| to_ca_file.action do |, , args| log_filename = args[0] CycleAnalyst.log_to_ca_file(log_filename) end end pre do |global,command,,args| # Pre logic here # Return true to proceed; false to abort and not call the # chosen command # Use skips_pre before a command to skip this block # on that command only @quiet = global[:quiet] # Handle that loop_count can be :forever or an Integer @loop_count = if global[:loop_count] == :forever Float::INFINITY else global[:loop_count].to_i end @enable_phaserunner = global[:enable_phaserunner] @enable_gps = global[:enable_gps] true end post do |global,command,,args| # Post logic here # Use skips_post before a command to skip this # block on that command only end on_error do |exception| # Error logic here # return false to skip default error handling true end exit run(ARGV) end |