That's

Scriptalicious!

Light speed script

beautification

Have you ever written a script that's...

Short

Fairly straightforward

got a handful of options

BUT...

needs to be “handed over” to PRODUCTION?

THEN SCRIPTALICIOUS COULD BE FOR YOU!!

Features

Unified -h help page and POD, eg `synopsis' is used for `usage'.

say “Got Perl 6?”

Huffman coded alternatives barf, moan, abort, mutter, whisper

run other programs safely (can capture or stdout&err and even connect filehandles to closures)

heirarchical semi-automatic config file support

quick and dirty prompting with validation: eg prompt_for(int => “iterations”)

no extra library dependancies but modules like Term::ReadLine can enhance features

Config is via YAML

Features, continued

...which rhymes with CAMEL!!

YAML, YAML, YAML!!

Step 1.

Locate one fresh juicy script

Example Script

Step 2.

Pour on Scriptalicious!

PERL!

emacs abbrev-mode

highly recommended

or just copy template

from the perldoc

lots of stuff to cue

you for what the

script needs

to follow “best practice”

Example Script

Step 3.

Beat script into submission!

Example Script

Original Script

Scriptalicious?

Isn't that just

Step 4.

Add POD according to taste

Example Script

Step 5.

Serve script piping hot to collegues!

Example Script

speights:~$ crypt-open

crypt-open: aborting: mount point /home/samv/crypto does not exist

Usage: (error: Pod::Constants failed to load)

Try `perldoc /home/samv/bin/crypt-open' for more information

speights:~$ crypt-open -x

crypt-open: aborting: unrecognised option: -x

Usage: (error: Pod::Constants failed to load)

Try `perldoc /home/samv/bin/crypt-open' for more information

speights:~$ crypt-open -h

crypt-open: warning: failed to extract usage information from POD; calling perldoc

speights:~$

...after installing Pod::Constants;

speights:~$ crypt-open

crypt-open: aborting: mount point /home/samv/crypto does not exist

Usage: crypt-open [options] { path }

Try `crypt-open --help' for a summary of options.

speights:~$ crypt-open -x

crypt-open: aborting: unrecognised option: -x

Usage: crypt-open [options] { path }

Try `crypt-open --help' for a summary of options.

speights:~$

Example Script

speights:~$ crypt-open --help

crypt-open - open personal crypto filesystem

Usage: crypt-open [options] { path }

This script opens up a Linux cryptographic filesystem. You will

need to set up the filesystem first, make a gpg encrypted key file,

and add an F</etc/fstab> entry that allows the user to mount the

filesystem. This is described later in the POD.

C<path> defaults to F<~/crypto>.

Command line options:

-h, --help Display a program usage screen and exit.

-V, --version Display program version and exit.

-v, --verbose Verbose command execution, displaying things

like the commands run, their output, etc.

-q, --quiet Suppress all normal program output; only

display errors and warnings.

-d, --debug Display output to help someone debug this

script, not the process going on.

-s, --sentinel Specify the `sentinel' file within the

mounted filesystem that tells us that it is

`open'. Defaults to F<.i_am_open>

-m, --mount Specify path of the mount point of the

filesystem, defaults to F<~/crypto>.

-f, --keyfile Specify path to the crypto filesystem key,

defaults to F<~/.crypto-key>.

See `perldoc /home/samv/bin/crypt-open' for more information.

speights:~$

YEAH YEAH YEAH

The POD-style C<path> bits weren't hidden

The --summary=FILE bits have been lost (a bug)

No super-convenient way to make pipelines 'safely'

doesn't scale to 'complicated' scripts very well (but KISS)

BUT WHO CARES...

After all...

It's in production!

So, it's

AN OPERATIONAL ISSUE

Credits

Getopt::Long

Term::ReadKey

Pod::Constants

Time::HiRes

Text::Wrap

Reinvented Wheels 2U

Test::More

Terminal Size Detection,

Raw Mode

POD ripping

Sub-second timing

Help Page Beautification

Config File Processing

Testing Framework

Command Line Processing

Command Execution, AUTOLOAD overlay system

Config File Processing

YAML

2005-03-12T14:48:08