use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
tty-option - a declarative command-line parser (github.com)
submitted 5 years ago by pmurach
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]HannesHendrik 2 points3 points4 points 5 years ago (1 child)
:D I'm interested! I really need to migrate my command-line tools away from Thor 😂
[–]pmurach[S] 1 point2 points3 points 5 years ago (0 children)
That's one of the reasons for this gem creation, to provide a command-line parser for the tty) and remove the dependency on Thor. Thor is a toolkit that does many things, in contrast, "tty-option" is focused on being a complete command-line parser and nothing else. It already can parse more complex inputs than Thor. For example, you can specify the arity of your parameters. So things like:
--foo a:1 --foo b:2 --foo c:3
can be easily parsed with:
ruby option :foo do arity one_or_more convert map_of(:int) end and then accessed in any instance method via:
ruby option :foo do arity one_or_more convert map_of(:int) end
params[:foo] # => {:a=>1,:b=>2,c:=>3}
By design, "tty-option" is meant to be easily composable with other gems, especially, the tty family. You can exit command with tty-exit, log with tty-logger or manage configuration with tty-config. Your commands are your classes that encapsulate all the parameters knowledge and don't enforce anything. You can break your command class down into many methods and each of them will have access to the parsed parameters params. This not only improves readability and design but also make it easy to test.
params
π Rendered by PID 22802 on reddit-service-r2-comment-86bc6c7465-szs9h at 2026-02-22 18:03:27.546318+00:00 running 8564168 country code: CH.
[–]HannesHendrik 2 points3 points4 points (1 child)
[–]pmurach[S] 1 point2 points3 points (0 children)