Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: 0.120001
Fetching contributors…

Cannot retrieve contributors at this time

81 lines (56 sloc) 2.519 kb


Command::Do - Simple Command-Line Interfaces


version 0.120001


in yourcmd:

use YourCmd;

in lib/

package YourCmd;
use Command::Do;

field name => {
    alias   => 'n',
    filters => ['trim', 'strip', 'titlecase'],
    default => 'Gorgeous'

command sub {
    my ($self, $options, $args) = @_;

    if ($self->validate('name')) {
        printf "You sure have a nice name, %s\n", $self->name;

and, finally, on the command line:

$ yourcmd
You sure have a nice name, Gorgeous

$ yourcmd --name=handsome
You sure have a nice name, Handsome

$ yourcmd -n=beautiful
You sure have a nice name, Beautiful


Command::Do is a simple toolkit for building simple yet sophisticated command-line applications. It includes very little magic (this is a feature, not a bug) and is useful when creating, validating, executing, and organizing command-line applications and actions. Command::Do inherits its functionality from Validation::Class which makes it and any namespace derived from it a Validation::Class, which allows you to focus-on and describe your command-line arguments and how they should be validated. Command::Do also uses Smart::Options for parsing command-line options.

Command::Do is very unassumming as thus flexible. It does not impose a particular application configuration and its dependencies are trivial and easily fatpacked. Command::Do does not render usage-text or auto-validate arguments, it simply provides you with the tools to do so wrapped-up in a nice DSL.

The name Command::Do is meant to convey the idea, command-and-do, i.e., write a command and do something! It is also a play on the word commando which is defined as a soldier specially trained to carry out raids; In English, the term commando usually means a person in an elite light infantry and/or special operations unit, specializing in amphibious landings, parachuting, rappelling and similar techniques, to conduct and effect attacks ... which is how I like to think about the command-line scripts I author.


Al Newkirk


This software is copyright (c) 2013 by Al Newkirk.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Jump to Line
Something went wrong with that request. Please try again.