samovar 2.3.0 → 2.4.1

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.
data/readme.md CHANGED
@@ -12,165 +12,41 @@ I've been using [Optimist](https://github.com/ManageIQ/optimist) and while it's
12
12
 
13
13
  One of the other issues I had with existing frameworks is testability. Most frameworks expect to have some pretty heavy logic directly in the binary executable, or at least don't structure your code in a way which makes testing easy. Samovar structures your command processing logic into classes which can be easily tested in isolation, which means that you can mock up and [spec your command-line executables easily](https://github.com/ioquatix/teapot/blob/master/spec/teapot/command_spec.rb).
14
14
 
15
- ## Examples
16
-
17
- - [Teapot](https://github.com/ioquatix/teapot/blob/master/lib/teapot/command.rb) is a build system and uses multiple top-level commands.
18
- - [Utopia](https://github.com/ioquatix/utopia/blob/master/lib/utopia/command.rb) is a web application platform and uses nested commands.
19
- - [Synco](https://github.com/ioquatix/synco/blob/master/lib/synco/command.rb) is a backup tool and sends commands across the network and has lots of options with default values.
20
-
21
- ## Installation
22
-
23
- Add this line to your application's Gemfile:
24
-
25
- gem 'samovar'
26
-
27
- And then execute:
28
-
29
- $ bundle
30
-
31
- Or install it yourself as:
32
-
33
- $ gem install samovar
34
-
35
15
  ## Usage
36
16
 
37
- Generally speaking, you should create `Command` classes that represent specific functions in your program. The top level command might look something like this:
38
-
39
- ``` ruby
40
- require 'samovar'
41
-
42
- class List < Samovar::Command
43
- self.description = "List the current directory"
44
-
45
- def call
46
- system("ls -lah")
47
- end
48
- end
49
-
50
- class Application < Samovar::Command
51
- options do
52
- option '--help', "Do you need help?"
53
- end
54
-
55
- nested :command, {
56
- 'list' => List
57
- }, default: 'list'
58
-
59
- def call
60
- if @options[:help]
61
- self.print_usage
62
- else
63
- @command.call
64
- end
65
- end
66
- end
67
-
68
- Application.call # Defaults to ARGV.
69
- ```
70
-
71
- ### Basic Options
17
+ Please see the [project documentation](https://ioquatix.github.io/samovar/) for more details.
72
18
 
73
- ``` ruby
74
- require 'samovar'
75
-
76
- class Application < Samovar::Command
77
- options do
78
- option '-f/--frobulate <text>', "Frobulate the text"
79
- option '-x | -y', "Specify either x or y axis.", key: :axis
80
- option '-F/--yeah/--flag', "A boolean flag with several forms."
81
- option '--things <a,b,c>', "A list of things" do |value|
82
- value.split(/\s*,\s*/)
83
- end
84
- end
85
- end
86
-
87
- application = Application.new(['-f', 'Algebraic!'])
88
- application.options[:frobulate] # 'Algebraic!'
89
-
90
- application = Application.new(['-x', '-y'])
91
- application.options[:axis] # :y
92
-
93
- application = Application.new(['-F'])
94
- application.options[:flag] # true
95
-
96
- application = Application.new(['--things', 'x,y,z'])
97
- application.options[:things] # ['x', 'y', 'z']
98
- ```
19
+ - [Getting Started](https://ioquatix.github.io/samovar/guides/getting-started/index) - This guide explains how to use `samovar` to build command-line tools and applications.
99
20
 
100
- ### Nested Commands
21
+ ## Releases
101
22
 
102
- ``` ruby
103
- require 'samovar'
104
-
105
- class Create < Samovar::Command
106
- def invoke(parent)
107
- puts "Creating"
108
- end
109
- end
110
-
111
- class Application < Samovar::Command
112
- nested '<command>',
113
- 'create' => Create
114
-
115
- def invoke(program_name: File.basename($0))
116
- if @command
117
- @command.invoke
118
- else
119
- print_usage(program_name)
120
- end
121
- end
122
- end
123
-
124
- Application.new(['create']).invoke
125
- ```
23
+ Please see the [project releases](https://ioquatix.github.io/samovar/releases/index) for all releases.
126
24
 
127
- ### ARGV Splits
25
+ ### v2.4.1
128
26
 
129
- ``` ruby
130
- require 'samovar'
27
+ ### v2.4.0
131
28
 
132
- class Application < Samovar::Command
133
- many :packages
134
- split :argv
135
- end
29
+ - Fix option parsing and validation: required options are now detected correctly and raise `Samovar::MissingValueError` when missing.
30
+ - Fix flag value parsing: flags that expect a value no longer consume a following flag as their value (e.g. `--config <path>` will not consume `--verbose`).
31
+ - Usage improvements: required options are marked as `(required)` in usage output.
136
32
 
137
- application = Application.new(['foo', 'bar', 'baz', '--', 'apples', 'oranges', 'feijoas'])
138
- application.packages # ['foo', 'bar', 'baz']
139
- application.argv # ['apples', 'oranges', 'feijoas']
140
- ```
33
+ ### v2.3.0
141
34
 
142
- ### Parsing Tokens
35
+ - Add support for `--[no]-thing` explicit boolean flags, allowing users to explicitly enable or disable boolean options.
143
36
 
144
- ``` ruby
145
- require 'samovar'
146
-
147
- class Application < Samovar::Command
148
- self.description = "Mix together your favorite things."
149
-
150
- one :fruit, "Name one fruit"
151
- many :cakes, "Any cakes you like"
152
- end
153
-
154
- application = Application.new(['apple', 'chocolate cake', 'fruit cake'])
155
- application.fruit # 'apple'
156
- application.cakes # ['chocolate cake', 'fruit cake']
157
- ```
37
+ ### v2.2.0
158
38
 
159
- ### Explicit Commands
39
+ - Add support for explicit output: commands can now specify an output stream (e.g. `STDOUT`, `STDERR`, or custom IO objects) via the `output:` parameter in `Command.call`.
160
40
 
161
- Given a custom `Samovar::Command` subclass, you can instantiate it with options:
41
+ ### v2.1.4
162
42
 
163
- ``` ruby
164
- application = Application['--root', path]
165
- ```
43
+ - `Command#to_s` now returns the class name by default, improving debugging and introspection.
166
44
 
167
- You can also duplicate an existing command instance with additions/changes:
45
+ ## See Also
168
46
 
169
- ``` ruby
170
- concurrent_application = application['--threads', 12]
171
- ```
172
-
173
- These forms can be useful when invoking one command from another, or in unit tests.
47
+ - [Teapot](https://github.com/ioquatix/teapot/blob/master/lib/teapot/command.rb) is a build system and uses multiple top-level commands.
48
+ - [Synco](https://github.com/ioquatix/synco/blob/master/lib/synco/command.rb) is a backup tool and sends commands across the network and has lots of options with default values.
49
+ - [Bake](https://github.com/ioquatix/bake) is an alternative task runner that makes it easy to expose Ruby methods as command-line tasks.
174
50
 
175
51
  ## Contributing
176
52
 
@@ -184,13 +60,13 @@ We welcome contributions to this project.
184
60
 
185
61
  ### Developer Certificate of Origin
186
62
 
187
- This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
63
+ 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.
188
64
 
189
- ### Contributor Covenant
65
+ ### Community Guidelines
190
66
 
191
- This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
67
+ 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.
192
68
 
193
- ## Future Work
69
+ ### Future Work
194
70
 
195
71
  ### Multi-value Options
196
72
 
data/releases.md ADDED
@@ -0,0 +1,21 @@
1
+ # Releases
2
+
3
+ ## v2.4.1
4
+
5
+ ## v2.4.0
6
+
7
+ - Fix option parsing and validation: required options are now detected correctly and raise `Samovar::MissingValueError` when missing.
8
+ - Fix flag value parsing: flags that expect a value no longer consume a following flag as their value (e.g. `--config <path>` will not consume `--verbose`).
9
+ - Usage improvements: required options are marked as `(required)` in usage output.
10
+
11
+ ## v2.3.0
12
+
13
+ - Add support for `--[no]-thing` explicit boolean flags, allowing users to explicitly enable or disable boolean options.
14
+
15
+ ## v2.2.0
16
+
17
+ - Add support for explicit output: commands can now specify an output stream (e.g. `STDOUT`, `STDERR`, or custom IO objects) via the `output:` parameter in `Command.call`.
18
+
19
+ ## v2.1.4
20
+
21
+ - `Command#to_s` now returns the class name by default, improving debugging and introspection.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,12 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samovar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  - Gabriel Mazetto
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain:
12
11
  - |
@@ -38,7 +37,7 @@ cert_chain:
38
37
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
39
38
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
40
39
  -----END CERTIFICATE-----
41
- date: 2024-03-28 00:00:00.000000000 Z
40
+ date: 1980-01-02 00:00:00.000000000 Z
42
41
  dependencies:
43
42
  - !ruby/object:Gem::Dependency
44
43
  name: console
@@ -68,12 +67,12 @@ dependencies:
68
67
  - - "~>"
69
68
  - !ruby/object:Gem::Version
70
69
  version: '1.0'
71
- description:
72
- email:
73
70
  executables: []
74
71
  extensions: []
75
72
  extra_rdoc_files: []
76
73
  files:
74
+ - context/getting-started.md
75
+ - context/index.yaml
77
76
  - lib/samovar.rb
78
77
  - lib/samovar/command.rb
79
78
  - lib/samovar/error.rb
@@ -95,12 +94,14 @@ files:
95
94
  - lib/samovar/version.rb
96
95
  - license.md
97
96
  - readme.md
97
+ - releases.md
98
98
  homepage: https://github.com/ioquatix/samovar
99
99
  licenses:
100
100
  - MIT
101
101
  metadata:
102
+ documentation_uri: https://ioquatix.github.io/samovar/
102
103
  funding_uri: https://github.com/sponsors/ioquatix/
103
- post_install_message:
104
+ source_code_uri: https://github.com/ioquatix/samovar.git
104
105
  rdoc_options: []
105
106
  require_paths:
106
107
  - lib
@@ -108,15 +109,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
109
  requirements:
109
110
  - - ">="
110
111
  - !ruby/object:Gem::Version
111
- version: '3.0'
112
+ version: '3.2'
112
113
  required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  requirements:
114
115
  - - ">="
115
116
  - !ruby/object:Gem::Version
116
117
  version: '0'
117
118
  requirements: []
118
- rubygems_version: 3.5.3
119
- signing_key:
119
+ rubygems_version: 3.6.9
120
120
  specification_version: 4
121
121
  summary: Samovar is a flexible option parser excellent support for sub-commands and
122
122
  help documentation.
metadata.gz.sig CHANGED
Binary file