main - code

cargs

about

cargs is a command-line utility which creates a single shell command from a multiline config file and then executes it.

cargs is written in Haskell. It's known to build under GHC 6.10.3

news

2009-05-10 (v1.0.1)
Initial release

documentation

This config file:

# cargs sample config file
# Here's the task that I wrote this program for: rsync backups

# Program to run
rsync

# Switches for the program
--archive
--verbose
#--relative
--delete
#--delete-excluded
#--filter '. /path/to/filter/file'
# Don't forget to comment the next one out!
--dry-run

# Non-switch arguments
# src path
/
# Root dir for the backup destination
/another/dir/cats/dogs
# Can be someplace remote
#ren@spumco.org:/foo/bar/backups

# Anything extra, maybe for redirection?
# We want rsync's stderr in the log too
2>&1
# Some other possibilities:
#2>&1 | tee -a /var/tmp/bak-foo.log
#2>&1 > /var/log/bak-foo.log

Becomes this command:

rsync --archive --verbose --delete --dry-run / /another/dir/cats/dogs 2>&1

cargs --help usage information:

cargs - Config file to args

Usage:
  cargs [OPTIONS] [CONFPATH]

CONFPATH  Path to a config file

Options:
  -h  --help       This help text
  -n  --no-action  Show command that would be executed, but do nothing
  -v  --verbose    Log events with timestamp such as conf file load, command execution and completion.

Example config files can be found in /usr/local/share/cargs-1.0.1/example

This program turns the contents of a config file into a shell command. 
And then executes it with timestamped log output.

Take care with wildly sending files to this thing. It sounds special 
when we say 'config file', but the reality is this program will 
de-comment, de-blankline and de-newline any file you give it and try 
to run the resulting string as a shell command. That's it, no magic.

The exit code will be that of the shell command that was executed. 
If this program fails before it gets that far (say, if you give it a 
bad option or no config path at all) it will exit with 255.

I have to admit that this software is of questionable utility. You 
can achieve something very similar by writing a shell script using 
backslash line continuation.

In its defense, my motivations were: Ability to mark-up the conf file 
with comments and whitespace. Handy no-action capability so you can 
confirm that your command line looks good. Timestamped log output of 
excution. And, it's just plain fun to write Haskell software.

Version 1.0.1  2009-May-09  Dino Morelli <dino@ui3.info>

getting it

older



last modified 2009-05-23