sterm 0.1.7 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00b43c04ea194dc6fe0f9db823b66bc358b207e2585740989fee98dc42cda3e8
4
- data.tar.gz: 7b99237e5e0c46c283613cbe984879b0079ba8ffc0d0b7a4016400100a63fc17
3
+ metadata.gz: 42886aeeeb2e631e038b7f5c6f5d0c7fe4edecb00c27ee273812520f158f3dba
4
+ data.tar.gz: fbd8d6b460e61a30607c712cf78e0bb930d04ccbe53118ab94b6025f5b508976
5
5
  SHA512:
6
- metadata.gz: f14dbc934815cc8500ceb3f64ca6cedbb2bfe9c6f18e44f7c1f68e61bebca28ed36383103cbec889be88c4178734a739ff57aeaa311af8db9ebb4e551169b217
7
- data.tar.gz: 71bc785216a934a1335a4a4c0cc7099bc3bf0ca6547aaedaa314e01bfd9040ba5624d720bd4b800eee203f26282bec57350bd2faf1fac70c34454279beb946ab
6
+ metadata.gz: b506f75384960314d6861ad643fad19215599e1e90fd691d2b77fc504224568dee46377859ff95f535d58cb245d616b1589a2b04fb885b940f20210032467ab9
7
+ data.tar.gz: 16f175435fd57734e9d72478a1a33d3919a68d69c1f8447185dff43bbaa84a153e0e874566df50a09017a46119331b16ac732b36a3f1b43e5ca2fe4ed1163796
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sterm (0.1.6)
4
+ sterm (0.1.7)
5
5
  rainbow (~> 3.0.0)
6
6
  serialport (~> 1.3.1)
7
7
 
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # SerialTerm
2
+ <p align="center">
3
+ <img width="196" height="150" src="https://files.cians.site/sterm_image.png">
4
+ </p>
2
5
  SerialTerm is a very simple command line tool to output data received from a serial device. It's built in ruby, and the <a href="https://rubygems.org/gems/serialport/versions/1.3.1" target="_blank">serialport</a> gem does most of the heavy lifting.
3
6
 
4
7
  I've only tested this with one device but it should work for anything that uses a serial output. If you find errors/exceptions feel free to report them or fix them and issue a pull request.
@@ -24,7 +27,7 @@ Default line ending is 0d0a (which is "\r\n" in hex).
24
27
 
25
28
  ## Contributing
26
29
 
27
- Bug reports and pull requests are welcome on GitHub at https://github.com/guineec/sterm.
30
+ Bug reports and pull requests are welcome on GitHub at https://github.com/guineec/serial-term.
28
31
 
29
32
  ## License
30
33
  This program is licensed under the <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt">GNU GPLv2.0</a> as required by the use of <a href="https://rubygems.org/gems/serialport/versions/1.3.1" target="_blank">serialport</a>.
data/lib/sterm.rb CHANGED
@@ -47,6 +47,10 @@ Usage: sterm DEVICE_PATH [options]\nTry starting with `sterm -h` for help\n\n}
47
47
  opts[:ending] = ending
48
48
  end
49
49
 
50
+ options.on("-n", "--[no-]line-numbers", "Print numbers at the start of each line of output (Default: true)") do |nums|
51
+ opts[:line_numbers] = nums
52
+ end
53
+
50
54
  options.on_tail("-v", "--version", "Show version") do
51
55
  puts Rainbow("SerialTerm version:").aqua + " #{Sterm::VERSION}"
52
56
  exit
@@ -94,6 +98,10 @@ Usage: sterm DEVICE_PATH [options]\nTry starting with `sterm -h` for help\n\n}
94
98
  puts Rainbow("INFO:").aqua + " Using default line ending of \"ODOA\" (\\r\\n)."
95
99
  end
96
100
 
101
+ if opts[:line_numbers].nil?
102
+ opts[:line_numbers] = true
103
+ end
104
+
97
105
  begin
98
106
  sp = SerialPort.new(device_path, baud_rate, data_bits, stop_bits, SerialPort::NONE)
99
107
  rescue Errno::ENOENT
@@ -107,9 +115,19 @@ Usage: sterm DEVICE_PATH [options]\nTry starting with `sterm -h` for help\n\n}
107
115
  end
108
116
 
109
117
  puts Rainbow("CONNECT: ").green + " Connected to device at " + device_path
110
-
118
+
119
+ line_num = 1
111
120
  while (line = sp.readline(line_end))
112
- puts Rainbow(device_path + ": ").yellow + line.chomp!
121
+ nspaces = (6 - (line_num.to_s.length))
122
+ nspaces = 1 if nspaces < 1
123
+ line_num_text = "[#{line_num}]" + (" " * nspaces)
124
+
125
+ if opts[:line_numbers]
126
+ puts line_num_text + Rainbow(device_path + ": ").yellow + line.chomp!
127
+ line_num += 1
128
+ else
129
+ puts Rainbow(device_path + ": ").yellow + line.chomp!
130
+ end
113
131
  end
114
132
  end
115
133
  end
data/lib/sterm/version.rb CHANGED
@@ -16,5 +16,5 @@
16
16
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
 
18
18
  module Sterm
19
- VERSION = "0.1.7"
19
+ VERSION = "0.2.0"
20
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sterm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cian Guinee