Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cfget(1) [debian man page]

CFGET(1)							   User Commands							  CFGET(1)

NAME
cfget - get values from a config file SYNOPSIS
cfget [options] section/key cfget [options] --dump=STYLE [section/key [section/key...]] cfget [options] --template=STYLE [infile [outfile]] DESCRIPTION
Get values from a config file. cfget is a simple tool to read values from configuration files. It is useful, for example, to create configurable shellscripts or make- files. It can also be configured to support virtual configuration values that, if not present in the config file, are automatically computed from the existing values. This makes it convenient, for example, to get a "duration" value from a configuration file that only contains a "start date" and an "end date". OPTIONS
--version show program's version number and exit -h, --help show this help message and exit -q, --quiet quiet mode: only output fatal errors -v, --verbose verbose mode --debug verbose mode -C file, --cfg=file config file to read; the option can be given more than once to read more than one file. If missing, read a colon separated list from the CFGET_CFG env variable. -P file, --plugin=file list of plugin files or directories to load. The option can be given more than once to read more than one file. If missing, read a colon separated list from the CFGET_PLUGINS env variable. -d name, --dump=name dump the contents of the database using the given style. Use '--dump=list' for a list of available styles. If one or more paths are provided in the command line, dump only those paths, otherwise dump all. -t name, --template=name read a template file, expand template placeholders using the configuration data and output the result. Use '--template=list' for a list of available styles. -f name, --format=name use a custom configuration file format (default: ini). Use '--format=list' for a list of available formats. The CFGET_FORMAT envi- ronment value, if defined, can be used to provide a different default value. -r path, --root=path restrict all work to values under the given path EXAMPLES
# Get a key from a config file cfget -C file.ini general/name # More can be specified, they will be searched in order cfget -C general.ini -C local.ini general/name # Use a plugin to add virtual entries cfget -C file.ini --plugin=virtual.py general/name # A plugin can also a directory containing .py files # and plugins can also be specified more than once cfget -C file.ini --plugin=virtual.py --plugin=virtual/ general/name # In a shellscript, you may want to use environment variables if you # invoke cfget many times: #!/bin/sh CFGET_CFG=general.ini:local.ini CFGET_PLUGINS=virtual.py:virtual/ START=`cfget general/start` END=`cfget general/end` DURATION=`cfget general/duration` # Quick way to copy all config values to the environment eval `cfget --dump=exports -C file.ini` # Autoconf-style template substitution cfget --template=autoconf -C file.ini script.in script # Curly braces substitude literally cfget -C file.ini "general/start_{general/type}" # One can use simple expressions cfget -C file.ini "general/start + general/duration" cfget -C file.ini "round(general/age / 2)" AUTHOR
cfget has been written by Enrico Zini <enrico@enricozini.org>. cfget 0.15 July 2010 CFGET(1)

Check Out this Related Man Page

inifile(n)						   Parsing of Windows INI files 						inifile(n)

__________________________________________________________________________________________________________________________________________________

NAME
inifile - Parsing of Windows INI files SYNOPSIS
package require Tcl 8.2 package require inifile ?0.2.3? ::ini::open file ?access? ::ini::close ini ::ini::commit ini ::ini::revert ini ::ini::filename ini ::ini::sections ini ::ini::keys ini section ::ini::get ini section ::ini::exists ini section ?key? ::ini::value ini section key ?default? ::ini::set ini section key value ::ini::delete ini section ?key? ::ini::comment ini section ?key? ?text? ::ini::commentchar ?char? _________________________________________________________________ DESCRIPTION
This package provides an interface for easy manipulation of Windows INI files. ::ini::open file ?access? Opens an INI file and returns a handle that is used by other commands. access is the same as the first form (non POSIX) of the open command, with the exception that mode a is not supported. The default mode is r+. ::ini::close ini Close the specified handle. If any changes were made and not written by commit they are lost. ::ini::commit ini Writes the file and all changes to disk. The sections are written in arbitrary order. The keys in a section are written in alphabet- ical order. If the ini was opened in read only mode an error will be thrown. ::ini::revert ini Rolls all changes made to the inifile object back to the last committed state. ::ini::filename ini Returns the name of the file the ini object is associated with. ::ini::sections ini Returns a list of all the names of the existing sections in the file handle specified. ::ini::keys ini section Returns a list of all they key names in the section and file specified. ::ini::get ini section Returns a list of key value pairs that exist in the section and file specified. ::ini::exists ini section ?key? Returns a boolean value indicating the existance of the specified section as a whole or the specified key within that section. ::ini::value ini section key ?default? Returns the value of the named key and section. If specified, the default value will be returned if the key does not exist. If the key does not exist and no default is specified an error will be thrown. ::ini::set ini section key value Sets the value of the key in the specified section. If the section does not exist then a new one is created. ::ini::delete ini section ?key? Removes the key or the entire section and all its keys. A section is not automatically deleted when it has no remaining keys. ::ini::comment ini section ?key? ?text? Reads and modifies comments for sections and keys. To write a section comment use an empty string for the key. To remove all com- ments use an empty string for text. text may consist of a list of lines or one single line. Any embedded newlines in text are prop- erly handled. Comments may be written to nonexistant sections or keys and will not return an error. Reading a comment from a nonex- istant section or key will return an empty string. ::ini::commentchar ?char? Reads and sets the comment character. Lines that begin with this character are treated as comments. When comments are written out each line is preceded by this character. The default is ;. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category inifile of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. CATEGORY
Text processing inifile 0.2.3 inifile(n)
Man Page