开发者

Is there a command line framework for ruby? [closed]

开发者 https://www.devze.com 2022-12-12 11:21 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answe开发者_Go百科rs.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answe开发者_Go百科rs.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 6 years ago.

Improve this question

So, there are web frameworks, there are GUI frameworks, I was just wondering if there was a console/command line framework for ruby?

Specifically, I would like to be able to:

  1. Have a particular view wherein I could tab to different input segments. Exactly like you can do with forms on a web page.
  2. I would like the usual console shortcuts to work (ctr-k, ctr-a, ctr-e, etc)
  3. If the cursor is at a certain input position, sometimes I would like it to response to a single key press event, rather than my having to enter text and then press enter.

Does not have to be a unified framework. But I notice that it does seem somewhat cumbersome to write console apps in ruby. Are there any tools that make this easier?


Judging from your questions it sounds like your like looking for curses-based frameworks. But in case that you're not, here are some console/irb-related gems I've written that may be useful:

  • hirb - view framework for associating classes with views
  • bond - custom readline completion made easy
  • boson - console command framework

Now to answer your questions:

  1. Though I don't know how to do it, there is this nice curses app whose source code you could read.
  2. require 'readline' gives you those keybindings
  3. require 'highline'; answer = HighLine.new.ask('ask something') {|e| e.character = true }


Maybe http://rbcurse.rubyforge.org/ can help


Found two more (used neither though):

  • Ruby Dialog Interface and
  • STFL

By the way, I think you had library, not framework in mind. It's a bit unrealistic expecting someone to develop console-based MVC framework... Anyway, everyone is free to try porting Rails... ;)

Actually, using text-based browser with a web application written with accessibility in mind could give you what you need. Plus you get a web interface for free!


I think SimpleConsole is what you are looking for:

It’s a tiny framework to get console applications developed quickly. It might be overkill for scripts, but is pretty useful for some applications. [...] SimpleConsole has a controller and a view, the controller sets up variables for the view to present. The view is optional, but is handy in the cases that you have a lot of ‘puts’ methods and you want to separate them from your logic.


This is what you are looking for: Luc.ie http://my.luc.ie/

Lucie is an MVC pattern based console application framework written in Ruby.


I added this above, adding as a separate answer as well so that it can be evaluated on its own.

Try out cliqr. It is a lightweight yet a powerful framework that comes with a bunch of features pre-built (including a shell for your command). Take a look at the examples in the git repository.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号