8 ms·
Ruby terminal apps toolkit
- trishume 10y agoThe progress bar gem looks pretty nice. I've been using the similar https://github.com/toy/progress https://github.com/toy/progress for a long time and it's super useful. One thing I prefer about progress is that the default config includes an ETA, which is generally the thing I care most about. It's interface is also a little nicer. It's really nice to have an estimate on when a script might complete, so I know if I have to optimize it or if I can just leave it running for a while.
- psadauskas 10y agoShameless plug: I wrote a progress bar gem awhile back for that exact use-case: I wanted it to be as simple as possible to use, and show me an ETA for completion. Maybe you'll find this one useful, too. https://github.com/paul/progress_bar https://github.com/paul/progress_bar
- pmurach 10y agoI was aware of many progress bar libraries before writing tty-progressbar. The reason I ended up coding my own was to have a dead simple codebase - literally one file that does the job well. This makes it easy to maintain and receive contributions. In addition doing job well meant very extensible way to format the progress display, virtually a string with tokens.
- VeejayRampay 10y agoLooks modular, well-built and well documented. I'll definitely check it out next I need a terminal app or script. Thanks.
- piratebroadcast 10y agoWhat kind of terminal apps do you write? I havent had the need for one yet and am wondering what this tool is used for.
- Exuma 10y agoI write a lot of internal tools and such, so that is where it's useful (nothing really public facing)
- VeejayRampay 10y agoMaybe not "apps" per se, but my three main use cases in my daily chores are: * A ruby script that deploys our application * A ruby script that cleans up the repository after deploy * A terminal-based git script that runs through all modified files, shows me the diff and allows me to either [c]ommit, [d]iscard changes, [s]kip or [q] before I commit. That last script is a prime candidate to use those tty-* gems.
- matt4077 10y agoI have a bunch of scientific data pipelines and have found rake to be an excellent tool for these. Same for a bunch of "housekeeping" scripts. Rake is seriously underrated I believe. It allows for dependencies and rules, figures out which steps are up-to-date and skips those, allows easy parallelisation etc. Much like make, but with the familiar and sane (ye beautiful) syntax of ruby and its extensive ecosystem.
- kondro 10y agoWhat does everyone suggest for command-line options parsing? This seems to be missing from the gemset and I've never found any of the existing solutions to be very intuitive.
- jfe 10y agohand-roll it. a 3-minute programming task doesn't warrant pulling in a graph of dependencies a la leftpad.
- deleted 10y ago[deleted]
- kondro 10y agoBut hand rolling is also hard and annoying to support if you want to support long-name options and short name optionals, out of order with potential spaces in odd places that still work as most users will expect them to along with reasonable usage-instruction documetantation.
- bglusman 10y agoSee comment about Thor
- matthewmacleod 10y agoNever do this. There are a basket of edge-cases and weirdness that you'll miss in your three-minute re-implementation that aren't worth that pain you'll have using or debugging later on.
- cturner 10y agoThere's a better alternative: don't have complex usage in the first place. You can get all the functionality you want by having multiple executables calling a common library. Consider netcat. You read the man page, and try to do something following its advice. Often enough, it just doesn't work. Because it's trying to cover a range of unrelated usages through a single entrypoint. It's easy to set up multiple exes cleanly. Have a non-executable module that contains the functions that your application requires (e.g. call it lib.rb). For each distinct usage, create a separate executable script that imports lib.rb, extracts a, b and c from the for just that usage and then call lib.usage(a, b, c). Users will find this easy to discover. You will find it easy to maintain, even compared to dedicated parsing DSLs. We don't special-case functions to do multiple things based on complex argument cases. We just create well-defined functions. We should think of executables in the same terms.
- niftich 10y agoA great toolkit -- there's a bunch of goodies here, but tty-table is amazing, from the sensible API to the configurable ASCII to Unicode renderer. It compares favorably with Hirb, the only other library I know of that draws console tables and supports Unicode box drawing characters.
- pmurach 10y agoRegarding tty-table, I have number of things planned including different renderer types to account for more esoteric formats and also very simple formats like tsv(table separate values) etc...
- xuejie 10y agoI wonder how easy it is to port all those libraries to mruby's mrbgems, so we can easily pack the Ruby-based CLI program as a single binary to get Go-like benefits.
- OhSoHumble 10y agoYeah, building Golang based command line tools is a big bag of pros and cons. There are so many libraries out there for Ruby and Python but having to manage packaging applications written in those languages can be kind of annoying.
- eikenberry 10y agoPython and Ruby really shine for scripting when the OS already has the packages installed. Otherwise not so much and a mostly self contained binary like Go produces would be better.
- pmurach 10y agoVery interesting. I haven't considered mruby but it makes perfect sense. Though I don't know how the situation looks like with regards to standard library? A lot of tty packages use esoteric stuff from Ruby standard libraries including ffi or console modules. There is still plenty of scripts that I write that are geared towards development workflow. I haven't had issues on setting up these tools on Debian servers, Ruby is usually preinstalled and all you need is bundler to get what you need.
- hopsoft 10y agoWhat about Traveling Ruby? I've never used it, but it looks promising. https://github.com/phusion/traveling-ruby https://github.com/phusion/traveling-ruby
- mega-tux 10y agoor use something similar to Ruby like Crystal lang
- transfire 10y agoLooks promising -- definitely a lot of work went into it. The closest other gem I know of is Ruby ANSI (http://rubyworks.github.io/ansi/# http://rubyworks.github.io/ansi/#)
- dkarapetyan 10y agoI've used this toolkit. It's pretty well done. The tabular ASCII capabilities tty-table are pretty neat.
- meow_mix 10y agoRuby is a fantastic language for writing command line tools. String interpolation and regex are great on it, easy to use OO principles as well as functional principals, etc. Definitely going to be writing wrappers over some of my favorite unix commands with this!
- pmurach 10y agoExactly my view. I'm planning to give a talk about Ruby scripting this year and would welcome any references to the tools that people built with tty. Please get in touch once you have anything to show.
- PerusingAround 10y agoIs there something similar but for Python?
- general_ai 10y ago+1, would be great to have something like that as an integrated toolkit on the Python (more specifically, Python 3) side. I currently use tqdm for progress bar, but it'd be great to also have a spinner and the rest of the goodies.
- cls59 10y agoThe Cement CLI framework for python looks similar: http://builtoncement.com/ http://builtoncement.com/
- y4mi 10y agolots of cli frameworks around... but most arent as comprehensive or well documented as the OPs. i personally like plumbum, but its definitely not the same. https://github.com/tomerfiliba/plumbum https://github.com/tomerfiliba/plumbum
- throwawayish 10y agoI don't think anything is missing, but you don't get it all in one package. click ( http://click.pocoo.org/6/ http://click.pocoo.org/6/ ) has a lot of this stuff in one package, but not everything, eg. composable command lines, progress bars, spinners, prompts, bash completion, colors, paging, launching common applications ($EDITOR) 'n stuff like that. pyinvoke has a somewhat different focus, but also quite some stuff similar to this. clint ( https://github.com/kennethreitz/clint https://github.com/kennethreitz/clint ) is another bag of tools, with things like awesome tables, colors, progress bars, ...
- growt 10y agoNot sure if it's welche here, but I wrote a Seminar lib for PHP: https://github.com/grothkopp/PHPCliWrapper https://github.com/grothkopp/PHPCliWrapper
- growt 10y agos/Seminar/similar/ (damn autocorrect :))
- Anthony-G 10y ago“welche?” – the German word doesn’t make sense in this context so I presume it’s another autocorrect typo (perhaps “welcome”)? If so, I upvoted your post to show that it is welcome (and useful).
- growt 10y agothank you, you're right about "welche"->"welcome
- throw2016 10y agoRuby apps are by far the most time consuming to configure and install. Nothing is simple. Nothing just works. The whole idea of exposing end users to your apps's depencies and compilation is a broken user hostile model. The potential rabbit hole of versions incompatibilities and mismatches is a time sink that cannot be justified. Go is by far the simplest hassle free deploy followed by PHP and Python. For a unix command line tool that seeks a userbase beyond Ruby users Go or Python would be the most user friendly choice.
- pmurach 10y agoMany systems come preinstalled with Ruby. Bundler is a very elegant and simple solution - I don't think it is hostile. Quite often the tools that we build are written by developers for developers or system administrators. For example Puppet or Chef. In my experience, these are people how don't mind running couple commands to get started. If anything I have heard people say really positive things on how easy and pain free installation is. Of course, if you want to write portable code that works on any system then Go is a very wise solution.
- MrBra 10y agoOk neat, but Ruby needs a serious and modern GUI toolkit!