NAME

configcmd - Store command line options in a file for future use

VERSION

version 0.002

SYNOPSIS

configcmd [--version | [-?|-h|--help] | section options

configcmd subprgm -j 8 --verbose

DESCRIPTION

configcmd takes any POSIX command line with GNU extensions and stores it in a configuration file that can be later read into a program and passed to the sub-program. This simplifies the input for command line scripts that are repeatedly run in different complex environments. The main program should be using the module Config::Cmd that is used by configcmd to process the information from the appropriate config file.

The first argument to the program is special -- it determines the file name the configuration is written into. The file name is the string appended with '_conf.yaml' since the configuration is written in YAML language.

This module does not do any interpretation of the options. It only does a simple sanity check and stores the options. The interpretation is left to the code or program using these options. Programs that are commonly used with non-standard options (e.g. tar zxvf), do understand standard option syntax, so you need to use it here. The program does, however, recognize and convert options using the equal sign:

-a = b
# becomes
-a b

The used filename and the cleaned command line are printed to STDERR.

File format

The first argument to the program is used inside the YAML file as the section key. This gives some redundancy to the section information and the file can be renamed when needed. All other command line options are under this section name in an array. The options are stored as key value pairs, except simple options that contain only the key.

The simple command line given in the synopsis is turned into the following self-explanatory YAML:

---
subprgm:
  - key: -j
    value: 8
  - key: --verbose

Use of config files

The configuration files can be read in using any YAML format parser, Config::Auto, or the method Config::Cmd::get().

The config files in the working directory are recognized by the section name by Config::Cmd::get(). It also finds a similarly named hidden config file from user's home directory. Read more from Config::Cmd.

NAME

configcmd - Store command line options in a file for future use

SEE ALSO

Config::Cmd, Config::Auto

AUTHOR

Heikki Lehvaslaiho <heikki.lehvaslaiho@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Heikki Lehvaslaiho.

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