rbtext 0.3.1 → 0.3.3
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 +4 -4
- data/bin/ftext +33 -11
- data/lib/rbtext.rb +1 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c7c45db810d1c18c792fc0cb8c950a98b595f1e8b2f11f9a52cbd1208ec1b20
|
4
|
+
data.tar.gz: 7ea21e0558cecc832e0880cc8912c30b7a3ad71187826e4ecd74eb3761570a83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ec67a8716005d493a6f67e279452d5bf782af7bc7d1660bbccd6c7d81cc2f496ee5fd325957bbd884130ab8ae32139d3763a44a4426a70d02ed4819d7621ca9
|
7
|
+
data.tar.gz: 92971efd9ce33efa7f914022ccc0f3fbcce48047438c96085a19c997d74a92f5f1141e698dda11e617d8dc0864c65714b83d21befa795cce2f92b22e01acd0af
|
data/bin/ftext
CHANGED
@@ -1,26 +1,48 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require_relative '../lib/rbtext.rb'
|
3
|
+
require 'argparse'
|
3
4
|
|
4
|
-
|
5
|
+
opts = {
|
6
|
+
dump: { has_argument: false },
|
7
|
+
noreset: { has_argument: false },
|
8
|
+
stdin: { has_argument: false },
|
9
|
+
help: { has_argument: false }
|
10
|
+
}
|
5
11
|
|
6
|
-
|
12
|
+
switches = {}
|
13
|
+
|
14
|
+
args = ArgsParser::Args.new(options: opts, switches: switches)
|
15
|
+
|
16
|
+
if args.options[:help]
|
17
|
+
puts "RBtext ftext #{RBText.version}"
|
18
|
+
puts "Syntax: ftext [ftext] [options]"
|
19
|
+
puts "Options"
|
20
|
+
puts "--dump - Output actual escape codes"
|
21
|
+
puts "--noreset - Doesn't reset formatting when applying ftext to piped input"
|
22
|
+
puts "--stdin - Get ftext from pipe"
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
if STDIN.tty? && ARGV[0] # If no pipe input and argument provided
|
7
27
|
txt = ARGV[0].to_s
|
8
|
-
elsif
|
9
|
-
|
28
|
+
elsif !STDIN.tty? && args.options[:stdin] # If pipe input and no argument provided
|
29
|
+
ft = STDIN.gets
|
30
|
+
print R::Ft.new(ft)
|
31
|
+
exit
|
10
32
|
else
|
11
33
|
if ARGV[0]
|
12
34
|
txt = []
|
13
35
|
|
14
|
-
|
36
|
+
ftargs = args.data[0].split(',')
|
15
37
|
lines = STDIN.each_line.to_a
|
16
38
|
|
17
|
-
if
|
18
|
-
x = lines.length/
|
19
|
-
|
39
|
+
if ftargs.length < lines.length
|
40
|
+
x = lines.length/ftargs.length
|
41
|
+
ftargs = ftargs * (x+1)
|
20
42
|
end
|
21
43
|
|
22
44
|
(0..lines.length-1).each do |l|
|
23
|
-
txt << "#{"_.f:reset._" if !
|
45
|
+
txt << "#{"_.f:reset._" if !args.options[:noreset]}_.#{ftargs[l]}._"+lines[l].gsub("_", "\0004")
|
24
46
|
end
|
25
47
|
|
26
48
|
txt = txt.join
|
@@ -30,5 +52,5 @@ else
|
|
30
52
|
end
|
31
53
|
|
32
54
|
out = R::Ft.new(txt).to_s.gsub("\0004", "_")
|
33
|
-
print out.dump.sub("\"", "").reverse.sub("\"", "").reverse if
|
34
|
-
print out if !
|
55
|
+
print out.dump.sub("\"", "").reverse.sub("\"", "").reverse if args.options[:dump]
|
56
|
+
print out if !args.options[:dump]
|
data/lib/rbtext.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbtext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthias Lee
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: io-console
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.5.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: argparse
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.3
|
27
41
|
description: A gem for printing formatted text
|
28
42
|
email: matthias@matthiasclee.com
|
29
43
|
executables:
|
@@ -43,7 +57,7 @@ homepage: https://github.com/Matthiasclee/RBText
|
|
43
57
|
licenses:
|
44
58
|
- AGPL-3.0
|
45
59
|
metadata: {}
|
46
|
-
post_install_message:
|
60
|
+
post_install_message:
|
47
61
|
rdoc_options: []
|
48
62
|
require_paths:
|
49
63
|
- lib
|
@@ -59,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
73
|
version: '0'
|
60
74
|
requirements: []
|
61
75
|
rubygems_version: 3.1.6
|
62
|
-
signing_key:
|
76
|
+
signing_key:
|
63
77
|
specification_version: 4
|
64
78
|
summary: RBText
|
65
79
|
test_files: []
|