Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/junegunn/srsly

SRSLY? NO!
https://github.com/junegunn/srsly

Last synced: 28 days ago
JSON representation

SRSLY? NO!

Awesome Lists containing this project

README

        

```
..............................................
..####...#####....####...##....##..##...####..
.##......##..##..##......##.....####...##..##.
..####...#####....####...##......##.......##..
.....##..##..##......##..##......##......##...
..####...##..##...####...######..##......##...
..............................................
```

```ruby
require 'srsly'

r = SRSLY? # Default "Are you sure (Y/N)?" message
r = SRSLY? nil => :eof # Returns :eof on EOF (nil)

r = SRSLY? 'Continue (Y/N)? ' # Custom message
r = SRSLY? 'Continue (Y/N)? ', nil => :eof # Returns :eof on EOF

r = SRSLY? 'Seriously (Y/N/A)? ',
# Expected responses (Regexp or String)
/^y/i => true,
/^n/i => false,
/^a/i => :all,
# Other options
:error => 'Invalid input. Seriously (Y/N/A)? ',
:tries => 5,
:in => $stdin,
:out => $stdout

r = SRSLY? "A or B? ",
'A' => :a,
'B' => :b,
nil => :quit,
:tries => 5,
:error => proc { |got, try, total| print "#{got}? Try again (#{try}/#{total}) " },
:out => proc { |msg| print msg + '>> ' }
```