Build Awesome Command-Line Applications in Ruby: Control by David B. Copeland

By David B. Copeland

As Ruby seasoned David Copeland explains, writing a command-line program that's self-documenting, strong, adaptable and ceaselessly priceless is simpler than you may imagine. Ruby is especially fitted to this activity, because it combines high-level abstractions with "close to the metal" approach interplay wrapped up in a concise, readable syntax. additionally, Ruby has the aid of a wealthy atmosphere of open-source instruments and libraries.

Ten insightful chapters every one clarify and exhibit a command-line most sensible perform. You'll see the best way to use those instruments to raise the lowliest automation script to a maintainable, polished application.

You'll use unfastened, open resource parsers to create simple command-line interfaces in addition to command suites. You'll see tips to use defaults to maintain concepts uncomplicated for daily clients, whereas giving complex clients suggestions for extra advanced tasks.

There's no cause a command-line program should still lack documentation, no matter if it's a part of a support command or a guy web page; you'll discover whilst and the way to exploit either. Your trip from command-line beginner to seasoned ends with a glance at invaluable methods to checking out your apps, and comprises a few enjoyable concepts for outside-the-box, colourful interfaces that might pride your users.

With Ruby, the command line isn't really lifeless. lengthy dwell the command line.

What You Need:

All you'll desire is Ruby, and the facility to put in a couple of gem stones alongside the way in which. Examples written for Ruby 1.9.2, yet 1.8.7 should still paintings simply as well.

Show description

Read Online or Download Build Awesome Command-Line Applications in Ruby: Control Your Computer, Simplify Your Life PDF

Best development books

PET for Drug Development and Evaluation

Can drug improvement and review be more desirable by means of positron emission tomography (PET)? puppy is now good validated and lots of puppy centres perform networks that warrant the standard in their learn. puppy permits one to persist with the impact of a drug on various sufferers' metabolic parameters.

Languages, Methodologies and Development Tools for Multi-Agent Systems: First International Workshop, LADS 2007, Durham, UK, September 4-6, 2007. Revised Selected Papers

This e-book constitutes the completely refereed post-workshop complaints of the 1st foreign Workshop on Languages, Methodologies and improvement instruments for Multi-Agent platforms, LADS 2007, held in Durham, united kingdom, in September 2007. The workshop was once a part of MALLOW 2007, a federation of workshops on Multi-Agent Logics, Languages, and organisations.

Comorbid Conditions Among Children with Autism Spectrum Disorders

This ebook provides the similarities and intersections among Autism Spectrum problems and comorbid stipulations in youngsters. It describes the superiority and importance of comorbid stipulations taking place along with ASD that complicate prognosis and will probably result in beside the point remedy and damaging results.

Text Types and the History of English

The booklet includes methodological reflexions on shape, content material and serve as in a finished description of textual content types/genres. those issues are then exemplified intimately via analyses of person varieties similar to cooking recipes, ebook dedications, ads, jokes, and church hymns. The move of varieties and the diversity of current varieties are defined for Scotland and for India.

Extra resources for Build Awesome Command-Line Applications in Ruby: Control Your Computer, Simplify Your Life

Sample text

Download from Wow! com> report erratum • discuss 38 • Chapter 3. Be Helpful Ruby places all command-line arguments in an array called ARGV, which OptionParser modifies when parse! is called. OptionParser’s modification to ARGV is to remove all the options and arguments it knows about. What’s left in ARGV are the unparsed arguments, which you can safely treat as the arguments the user provided on the command line. Unrecognized switches and flags will cause OptionParser to print an error and exit your app, so you’ll never find them in ARGV.

Be_easy_to_use/todo/bin/todo switch :s flag :f This declares that the app accepts a global switch -s and a global flag -f. Remember, these are just examples; we’ll change them later to meet our app’s requirements. action do |global_options,options,args| # Your command logic here # If you have any errors, just raise them # raise "that command made no sense" end end The block given to command establishes a context to declare command-specific options via the argument passed to the block (c). GLI has provided an example of command-specific options by declaring that the new command accepts a switch -s and a flag -f.

There is great flexibility in the arguments to on, so the type of the argument, as well as its contents, controls how OptionParser will behave. For example, if a string is passed and it starts with a dash followed by one or more nonspace characters, it’s treated as a switch. If there is a space and another string, it’s treated as a flag. on("i","–iteration")), then these two options mean the same thing. Table 1, Overview of OptionParser parameters to on, on page 21 provides an overview of how a parameter to on will be interpreted; you can add as many parameters as you like, in any order.

Download PDF sample

Rated 4.32 of 5 – based on 20 votes