Skip to content
This repository

A tiny assistant for CUI operations.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 example
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 .yardopts
Octocat-spinner-32 Gemfile
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 io-nosey.gemspec
README.md

io-nosey

Build Status Gem Version

Description

A tiny assistant for CUI operations.

Features

  • #ask
  • #agree?
  • #choose
  • PureRuby :)

#ask's option parameter

input -> parse -> return

  1. input # validation for input string
  2. parse # procedure for input string
  3. return # validation for return value

Other

  • default # when null input
  • echo # set "echo is (true or false)"
  • error # change error message when invalid input
  • multi_line # prefer multi_line mode for inputs(exit via ctrl+d)

Usage

Tutorial

Try below senario on REPL(ex. irb, pry) or excute "example/**_tutorial.rb"

require 'io/nosey'
include IO::Nosey

# input validation
ask 'What\'s your name?("firstname lastname"): ', input: /\A\w+ \w+\z/

# mix the validations and procedures
ask 'How old are you?: ', input:  /\A(\d+)\z/,
                          parse:  ->s{Integer s},
                          return: 10..100

# default value
ask "What's your favorite?: ", default: 'ruby'

# yes or no
agree? 'Do you like this API?: '

# for password
ask "What's your password?: ", echo: false

# choose one from collections
choose 'Which Five do you like?: ',  5      => '5 is a Integer',
                                   'five' => '"five" is a String',
                                   :FIVE  => ':FIVE is a Symbol'

# multi line mode
ask 'Write your poem and exit ctrl+d :) ', multi_line: true

Requirements

Install

gem install io-nosey

Link

License

The MIT X11 License
Copyright (c) 2011 Kenichi Kamiya
See MIT-LICENSE for further details.

Something went wrong with that request. Please try again.