samovar 2.4.1 → 2.4.2
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
- checksums.yaml.gz.sig +0 -0
- data/lib/samovar/failure.rb +1 -1
- data/lib/samovar/many.rb +1 -1
- data/lib/samovar/nested.rb +1 -1
- data/lib/samovar/one.rb +1 -1
- data/lib/samovar/output/columns.rb +1 -1
- data/lib/samovar/output/header.rb +1 -1
- data/lib/samovar/output/usage_formatter.rb +41 -35
- data/lib/samovar/version.rb +1 -1
- data/license.md +2 -1
- data/readme.md +20 -2
- data/releases.md +3 -1
- data.tar.gz.sig +0 -0
- metadata +4 -17
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 467711ed04ecc759513ab6187d17a8c5208fa24869d202fb23a46217d3ceedab
|
|
4
|
+
data.tar.gz: 293c9e07e9f0ff0b9550b0ad3411b5e10f460a6c72dd8be2bc254d985dec95da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bf717af75e91db10dc75008e1421601181168190aa89ea5bd289ca5e832505d1382cee60ac7e1b66d4500673779cc2cc5325dc33110ce4871443fa93c820d817
|
|
7
|
+
data.tar.gz: c7c0f9b82b3ce5502c29da74b7810f69c63687237b2a7550dde8ff5eda35f3db6739848907d9669a2083df9ec186097c90d44e4e119aa1176ca1c6a52c7f6f07
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/samovar/failure.rb
CHANGED
data/lib/samovar/many.rb
CHANGED
data/lib/samovar/nested.rb
CHANGED
data/lib/samovar/one.rb
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
4
|
# Copyright, 2019-2025, by Samuel Williams.
|
|
5
|
+
# Copyright, 2026, by Gerhard Schlager.
|
|
5
6
|
|
|
6
|
-
require "mapping/model"
|
|
7
7
|
require "console/terminal"
|
|
8
8
|
|
|
9
9
|
require_relative "../error"
|
|
@@ -17,8 +17,8 @@ module Samovar
|
|
|
17
17
|
module Output
|
|
18
18
|
# Formats and prints usage information to a terminal.
|
|
19
19
|
#
|
|
20
|
-
#
|
|
21
|
-
class UsageFormatter
|
|
20
|
+
# Dispatches on the type of each output object to apply custom formatting rules.
|
|
21
|
+
class UsageFormatter
|
|
22
22
|
# Print usage information to the output.
|
|
23
23
|
#
|
|
24
24
|
# @parameter rows [Rows] The rows to format and print.
|
|
@@ -39,7 +39,6 @@ module Samovar
|
|
|
39
39
|
def initialize(output)
|
|
40
40
|
@output = output
|
|
41
41
|
@width = 80
|
|
42
|
-
@first = true
|
|
43
42
|
|
|
44
43
|
@terminal = Console::Terminal.for(@output)
|
|
45
44
|
@terminal[:header] = @terminal.style(nil, nil, :bright)
|
|
@@ -47,43 +46,50 @@ module Samovar
|
|
|
47
46
|
@terminal[:error] = @terminal.style(:red)
|
|
48
47
|
end
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
# Format and print the given object according to its type.
|
|
50
|
+
#
|
|
51
|
+
# @parameter object [Object] The object to format (a {Rows}, {Row}, {Header}, or error).
|
|
52
|
+
# @parameter arguments [Array] Extra context passed through to nested rows (the containing {Rows}).
|
|
53
|
+
def map(object, *arguments, first: true)
|
|
54
|
+
case object
|
|
55
|
+
when InvalidInputError
|
|
56
|
+
# This is a little hack which avoids printing out "--help" if it was part of an incomplete parse. In the future I'd prefer if this was handled explicitly.
|
|
57
|
+
@terminal.puts("#{object.message} in:", style: :error) unless object.help?
|
|
58
|
+
when MissingValueError
|
|
59
|
+
@terminal.puts("#{object.message} in:", style: :error)
|
|
60
|
+
when Header
|
|
61
|
+
header, rows = object, arguments.first
|
|
62
|
+
|
|
63
|
+
if first
|
|
64
|
+
first = false
|
|
65
|
+
else
|
|
66
|
+
@terminal.puts
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
command_line = header.object.command_line(header.name)
|
|
70
|
+
@terminal.puts "#{rows.indentation}#{command_line}", style: :header
|
|
71
|
+
|
|
72
|
+
if description = header.object.description
|
|
73
|
+
@terminal.puts "#{rows.indentation}\t#{description}", style: :description
|
|
74
|
+
@terminal.puts
|
|
75
|
+
end
|
|
76
|
+
when Row
|
|
77
|
+
row, rows = object, arguments.first
|
|
78
|
+
@terminal.puts "#{rows.indentation}#{row.align(rows.columns)}"
|
|
79
|
+
when Rows
|
|
80
|
+
object.each do |row, rows|
|
|
81
|
+
first = map(row, rows, first: first)
|
|
82
|
+
end
|
|
62
83
|
else
|
|
63
|
-
|
|
84
|
+
raise ArgumentError, "Unable to format #{object.class}!"
|
|
64
85
|
end
|
|
65
86
|
|
|
66
|
-
|
|
67
|
-
@terminal.puts "#{rows.indentation}#{command_line}", style: :header
|
|
68
|
-
|
|
69
|
-
if description = header.object.description
|
|
70
|
-
@terminal.puts "#{rows.indentation}\t#{description}", style: :description
|
|
71
|
-
@terminal.puts
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
map(Row) do |row, rows|
|
|
76
|
-
@terminal.puts "#{rows.indentation}#{row.align(rows.columns)}"
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
map(Rows) do |items|
|
|
80
|
-
items.collect{|row, rows| map(row, rows)}
|
|
87
|
+
return first
|
|
81
88
|
end
|
|
82
89
|
|
|
83
90
|
# Print the formatted usage output.
|
|
84
|
-
def print(rows, first:
|
|
85
|
-
|
|
86
|
-
map(rows)
|
|
91
|
+
def print(rows, first: true)
|
|
92
|
+
map(rows, first: first)
|
|
87
93
|
end
|
|
88
94
|
end
|
|
89
95
|
end
|
data/lib/samovar/version.rb
CHANGED
data/license.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# MIT License
|
|
2
2
|
|
|
3
|
-
Copyright, 2016-
|
|
3
|
+
Copyright, 2016-2026, by Samuel Williams.
|
|
4
4
|
Copyright, 2018, by Gabriel Mazetto.
|
|
5
|
+
Copyright, 2026, by Gerhard Schlager.
|
|
5
6
|
|
|
6
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
8
|
of this software and associated documentation files (the "Software"), to deal
|
data/readme.md
CHANGED
|
@@ -22,7 +22,9 @@ Please see the [project documentation](https://ioquatix.github.io/samovar/) for
|
|
|
22
22
|
|
|
23
23
|
Please see the [project releases](https://ioquatix.github.io/samovar/releases/index) for all releases.
|
|
24
24
|
|
|
25
|
-
### v2.4.
|
|
25
|
+
### v2.4.2
|
|
26
|
+
|
|
27
|
+
- Drop dependency on `mapping` gem.
|
|
26
28
|
|
|
27
29
|
### v2.4.0
|
|
28
30
|
|
|
@@ -58,6 +60,22 @@ We welcome contributions to this project.
|
|
|
58
60
|
4. Push to the branch (`git push origin my-new-feature`).
|
|
59
61
|
5. Create new Pull Request.
|
|
60
62
|
|
|
63
|
+
### Running Tests
|
|
64
|
+
|
|
65
|
+
To run the test suite:
|
|
66
|
+
|
|
67
|
+
``` shell
|
|
68
|
+
bundle exec sus
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Making Releases
|
|
72
|
+
|
|
73
|
+
To make a new release:
|
|
74
|
+
|
|
75
|
+
``` shell
|
|
76
|
+
bundle exec bake gem:release:patch # or minor or major
|
|
77
|
+
```
|
|
78
|
+
|
|
61
79
|
### Developer Certificate of Origin
|
|
62
80
|
|
|
63
81
|
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
|
@@ -66,7 +84,7 @@ In order to protect users of this project, we require all contributors to comply
|
|
|
66
84
|
|
|
67
85
|
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
|
68
86
|
|
|
69
|
-
|
|
87
|
+
## Future Work
|
|
70
88
|
|
|
71
89
|
### Multi-value Options
|
|
72
90
|
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: samovar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.4.
|
|
4
|
+
version: 2.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
8
8
|
- Gabriel Mazetto
|
|
9
|
+
- Gerhard Schlager
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain:
|
|
11
12
|
- |
|
|
@@ -53,20 +54,6 @@ dependencies:
|
|
|
53
54
|
- - "~>"
|
|
54
55
|
- !ruby/object:Gem::Version
|
|
55
56
|
version: '1.0'
|
|
56
|
-
- !ruby/object:Gem::Dependency
|
|
57
|
-
name: mapping
|
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
|
59
|
-
requirements:
|
|
60
|
-
- - "~>"
|
|
61
|
-
- !ruby/object:Gem::Version
|
|
62
|
-
version: '1.0'
|
|
63
|
-
type: :runtime
|
|
64
|
-
prerelease: false
|
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
-
requirements:
|
|
67
|
-
- - "~>"
|
|
68
|
-
- !ruby/object:Gem::Version
|
|
69
|
-
version: '1.0'
|
|
70
57
|
executables: []
|
|
71
58
|
extensions: []
|
|
72
59
|
extra_rdoc_files: []
|
|
@@ -109,14 +96,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
109
96
|
requirements:
|
|
110
97
|
- - ">="
|
|
111
98
|
- !ruby/object:Gem::Version
|
|
112
|
-
version: '3.
|
|
99
|
+
version: '3.3'
|
|
113
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
101
|
requirements:
|
|
115
102
|
- - ">="
|
|
116
103
|
- !ruby/object:Gem::Version
|
|
117
104
|
version: '0'
|
|
118
105
|
requirements: []
|
|
119
|
-
rubygems_version:
|
|
106
|
+
rubygems_version: 4.0.10
|
|
120
107
|
specification_version: 4
|
|
121
108
|
summary: Samovar is a flexible option parser excellent support for sub-commands and
|
|
122
109
|
help documentation.
|
metadata.gz.sig
CHANGED
|
Binary file
|