[ Home | Main Table Of Contents | Table Of Contents | Keyword Index ]

cmdr::config(n) 1.0 doc "Cmdr, a framework for command line parsing and dispatch"

Name

cmdr::config - Cmdr - (Partially internal) Collection of parameters for privates

Table Of Contents

Synopsis

Description

Welcome to the Cmdr project, written by Andreas Kupries.

For availability please read Cmdr - How To Get The Sources.

This package implements the collections of cmdr::parameters serving as the configuration of privates (see cmdr::private).

Class API

The class API is not public. It is used internally by the framework when parsing a command hierarchy specification to create the necessary configuration instances.

It is described here for use by developers maintaining, modifying and extending the framework itself. A user of the framework has no need for it.

::cmdr::config new context spec

Create an auto-named instance of cmdr::config.

Not used.

::cmdr::config create obj context spec

Create a new instance of cmdr::config, named obj.

string obj

The (command) name of the new config instance.

cmdr::config context

The instance command of the cmdr::private instance the configuration will belong to.

script spec

Tcl-script specifying the parameters in detail. Please read Cmdr - Parameter Specification Language for the details.

::cmdr::config interactive ?enable?

Class method to change the global interaction default for the mini-shell of privates. The default is to disable this mini-shell for all privates, and enable it on a per-private basis, through the specification.

boolean enable

Defaults to true, globally activating the mini-shell.

::cmdr::config display displaycmd

Class method to override the standard display command used by the mini-shell to show the current state of all parameters.

commandprefix displaycmd

The display command to use. The command will be called with a single argument, a list containing the names of the parameters to show. The command has to format the state of the requested parameters as a string and return this string as its result.

Instance API

Most of the instance API is not public.

It is described here for use by developers maintaining, modifying and extending the framework itself. A user of the framework has no need for it.

<config> @... ...

All parameters held by a configuration instance are accessible through it. To this end each parameter named foo has a dynamically created accessor method @foo taking the method and its arguments to apply to the parameter instance.

If no words are specified at all the system defaults to the application of instance method value.

Together with a parameter's ability to access the configuration holding it having access to a single parameter instance (like in the various callbacks) provides access to all.

list list
<config> arguments

This method returns a list of parameter names, for the parameters which are arguments.

<config> complete line

This method is part of the mini shell command line completion. For the details of its workings please read Cmdr - Internals of command line completion.

This hook-method, the entrypoint for the repl is responsible for computing the set of completions for the entered line.

string line

The command line to complete.

<config> complete-repl parse

This internal method is part of the mini shell command line completion. For the details of its workings please read Cmdr - Internals of command line completion.

It is used by the hook-method complete (see above). Given the completion state parse of a partial command line it returns a list of strings which are the valid completions at this point.

dict parse

A dictionary holding the current completion state of a partial command line.

<config> complete-words parse

This method is part of the main shell command line completion. For the details of its workings please read Cmdr - Internals of command line completion.

Given the completion state parse of a partial command line it returns a list of strings which are the valid completions at this point.

dict parse

A dictionary holding the current completion state of a partial command line.

<config> continued line

This hook-method for the mini-shell is responsible for the detection of a continuation-line in the entered command line. It always returns the boolean value false as the mini-shell does not support continuation lines.

list list
<config> dispatch cmd

This hook-method for the mini-shell is responsible for the recognition and execution of the supported commands.

string cmd

The command line containing the command to run.

<config> display ?plist?

This method formats the chosen parameters for display and returns the result as a string. This invokes the chosen display callback, if one was set. Without an internal formatter is used instead.

list plist

The list of parameters (by name) to format for display. If not specified the list default to the set of public parameters plus any undocumented parameters already set by the user.

<config> dump

This method formats all parameters for display, using the internal formatter, and returns the result as a string. Useful for debugging.

<config> eoptions

This method returns a dictionary mapping all possible option prefixes to a list of full option names with that prefix.

<config> exit

This hook-method for the mini-shell returns a boolean value indicating whether the mini-shell was stopped and has to exit (true), or not (false).

<config> force ?allowinteract? ?forcedefered?

This method forces the calculation of the values for all parameters in the configuration instance. This is the ''completion phase''.

boolean allowinteract

If specified as false parameters allowing the interactive entry of their value have this feature disabled for the operation. The default is true, allowing for the interaction.

boolean forcedefered

If specified as true even parameters marked as "defered" are forced to generate their value. The default is false, causing the method to ignore such parameters.

<config> forget

This method invokes the parameter method forget on all parameters in the configuration.

<config> has name

This method checks if the configuration instance contains a parameter with the specified name and returns a boolean value indicating whether the parameter exists (true), or not (false).

string name

The name of the parameter to check for existence

<config> help ?mode?

This method returns the help information for the parameters held in the configuration. The result of the command is a structure of the form described in section Help Information.

enum mode

The possible modes are public and interact. If not specified public is the default. In this mode only "documented" parameters are included in the help. In mode "interact", used by the mini-shell undocumented parameters are included as well, if they are already set by the user.

<config> interact

This method invokes the mini-shell for interactive parameter entry. It returns on exit from the shell. The result of the method is the empty string.

<config> interactive

This accessor method returns a boolean value indicating whether use of the mini-shell is allowed (true), or not (false).

<config> lookup name

This method checks if the configuration instance contains a parameter with the specified name and returns its instance. An error is thrown if the parameter is not known.

string name

The name of the parameter to retrieve.

<config> lookup-option name

This method checks if the configuration instance contains a parameter controlling the specified option name and returns its instance. An error is thrown if the option is not known.

string name

The option flag to find the controlling parameter for.

<config> missingOptionValue name

This method throws the standard error for when the option name requiring an argument value does not have one. See the methods notEnough and tooMany as well.

string name

The flag triggering the error.

<config> names

This method returns a list of parameter names, for all parameters.

<config> notEnough

This method throws the standard error for when a command is found to be supplied with not enough arguments for its parameters. See the methods missingOptionValue and tooMany as well.

<config> options

This method returns a list of the option flags recognized by the parameters in the configuration. This does not include option prefixes.

<config> parse ?word...?

This method parses the words (from the command line) and maps them to parameters, based on naming (options and flags), or position (arguments).

list word

The words of the command specifying the parameters of the private holding the configuration instance.

<config> parse-options

This method is a helper for parse above. Accessing the internal queue initialized by parse it splits arguments and options, processing all the latter. The arguments are put back into the queue, in the order they were found in. This is used by parameters (optional arguments) using the regular threshold-regime to determine acceptance. All options still in the command line must be removed (and processed) to know the proper number of arguments words left.

<config> prompt1

This hook-method for the mini-shell returns the primary prompt string to use.

<config> prompt2

This hook-method for the mini-shell returns the secondary prompt string for use within a continuation. As the mini-shell does not support continuation lines it should not be invoked ever, and thus always throws an error should it be invoked.

<config> public

This method a list of parameter names, for all documented option and argument parameters.

<config> raise msg ?word...?

This method is a helper for methods tooMany, notEnough, and missingOptionValue, doing the bulk of the work.

string msg

The human-readable error message to use.

list word

The machine-readable (trap-able) error code to use.

<config> report what data

This hook-method for the mini-shell is responsible for the reporting of the command results and handles the display of the parameter state before a new prompt.

Its result is the empty string.

enum what

The result code of the command, one of ok, or fail.

any data

The result of the command, or an error message in case of failure.

<config> reset

This method invokes the parameter method reset on all parameters in the configuration.

<config> self

This method returns the configuration instance itself.

<config> tooMany

This method throws the standard error for when a command is found to be supplied with too many arguments for its parameters. See the methods missingOptionValue and notEnough as well.

<config> unknown method ?word...?

This method is the hook into the TclOO method resolution for the class. It implements the dynamic accessor methods for the parameters held by the configuration instance. See method @... at the top.

list list

Help Information

The help information generated by various places of the framework is a dictionary containing the following keys:

arguments

A list of strings, the names of the command arguments, in order. These names are keys into the parameters sub-dictionary.

desc

The command's description, i.e. help text.

opt2para

A dictionary mapping option flags to option names. These names are keys into the parameters sub-dictionary.

options

A dictionary mapping option names to their descriptions.

parameters

A dictionary mapping parameter names to their definition. Each definition is a dictionary containing the keys below. See also package cmdr::parameter.

cmdline

Output of method cmdline.

code

Output of method code.

default

Output of method default.

defered

Output of method defered.

description

Output of method description.

documented

Output of method documented.

flags

A dictionary mapping flag names to flag types, i.e. primary, alias, or inverted.

generator

Output of method generator.

interactive

Output of method interactive.

isbool

Output of method isbool.

label

Output of method label.

list

Output of method list.

ordered

Output of method ordered.

presence

Output of method presence.

prompt

Output of method prompt.

required

Output of method required.

threshold

Output of method threshold.

type

Output of method type.

validator

Output of method validator.

sections

A list of sections the command belongs to. Each section name is a list itself, the path of the section and sub-sections.

states

A list of strings, the names of the command's hidden state parameters. These names are keys into the parameters sub-dictionary.

Bugs, Ideas, Feedback

Both the package(s) and this documentation will undoubtedly contain bugs and other problems. Please report such at Cmdr Tickets.

Please also report any ideas you may have for enhancements of either package(s) and/or documentation.

Keywords

arguments, command hierarchy, command line completion, command line handling, command tree, editing command line, help for command line, hierarchy of commands, interactive command shell, optional arguments, options, parameters, processing command line, tree of commands