SimpleSubcommand v1.0 

 The Simple Development Library subcommand procedures handling 

Project: the Simple Development Library.

Table of contents

1. Package description
   1.1 Overview
   1.2 Usage
   1.3 Examples
   1.4 History
   1.5 Copyright
2. Package public API
   2.1 Types
   2.2 Options
   2.3 Namespaces
   2.4 Commands
      2.4.1 ::Simple::Subcommand::cget
      2.4.2 ::Simple::Subcommand::configure
      2.4.3 proc-sub procedure arguments body
      2.4.4 ::Simple::Subcommand::delete procedure
      2.4.5 ::Simple::Subcommand::information exists command
      2.4.6 ::Simple::Subcommand::information subcommands command
      2.4.7 ::Simple::Subcommand::move sourceProcedure targetProcedure
   2.5 Errors
      2.5.1 ::Simple::Subcommand::CANT-CREATE
      2.5.2 ::Simple::Subcommand::CANT-DELETE-OR-RENAME
      2.5.3 ::Simple::Subcommand::NON-EXISTING-COMMAND
3. Package further information
   3.1 Details
4. Package command details
   4.1 ::Simple::Subcommand::cget
      4.1.1 Command description
      4.1.2 Command public API
   4.2 ::Simple::Subcommand::configure
      4.2.1 Command description
      4.2.2 Command public API
   4.3 proc-sub procedure arguments body
      4.3.1 Command description
         4.3.1.1 Overview
         4.3.1.2 Examples
      4.3.2 Command public API
      4.3.3 Command further information
         4.3.3.1 Details
         4.3.3.2 References
   4.4 ::Simple::Subcommand::delete procedure
      4.4.1 Command description
         4.4.1.1 Overview
      4.4.2 Command public API
      4.4.3 Command further information
         4.4.3.1 Details
   4.5 ::Simple::Subcommand::information exists command
      4.5.1 Command description
      4.5.2 Command public API
      4.5.3 Command further information
         4.5.3.1 Details
         4.5.3.2 References
   4.6 ::Simple::Subcommand::information subcommands command
      4.6.1 Command description
      4.6.2 Command public API
      4.6.3 Command further information
         4.6.3.1 References
         4.6.3.2 Remarks
   4.7 ::Simple::Subcommand::move sourceProcedure targetProcedure
      4.7.1 Command description
         4.7.1.1 Overview
      4.7.2 Command public API
      4.7.3 Command further information
         4.7.3.1 Details
         4.7.3.2 Remarks
         4.7.3.3 Todo

1. Package description

Synopsis: the Simple Development Library subcommand procedures handling.

Keywords: procedure, command, subcommand, family, composite and ensemble.

1.1 Overview

This package allows to handle subcommand procedures. Subcommands is The Simple Development Library term for the concept named ensemble commands, command families or composite commands in other contexts. Basically one can define the foo bar and foo gee commands, which are subcommands bar and gee for the foo base command; each subcommand has its own arguments.

Procedures are provided to create, delete, copy, rename and get information about subcommand procedures.

1.2 Usage

Subcommand procedures are create via the proc-sub command. Such subcommand procedures behave similarly to the built-in Tcl commands with subcommands (such as string or array):

Subcommand procedures can be deleted via ::Simple::Subcommand::delete or renamed via ::Simple::Subcommand::move. The ::Simple::Subcommand::information procedure provides several subcommands to query information about subcommand procedures: exists and subcommands.

1.3 Examples

1.4 History

Date Reason
23-apr-2000 First public release, version 0.2
10-sep-2001 Second public release, version 0.4
17-feb-2003 Third public release, version 0.5
29-mar-2003 Extra package, version 0.5.1
24-oct-2004 Bug 8 correction, version 0.5.2
24-oct-2004 Copy functionality deleted, version 0.5.3
10-feb-2005 Bug 9 correction, version 0.5.4
22-jun-2005 The Simple Development Library version 1.0

1.5 Copyright

Copyright (C) 1999-2005, Juan C. Gil (jgil@gmv.es).

2. Package public API

Paradigm: procedural.

Requisites: SimpleNamespace 1.0.

2.1 Types

None.

2.2 Options

None.

2.3 Namespaces

  1. ::Simple::Subcommand

  2. ::Simple::Subcommand::Priv

2.4 Commands

2.4.1 ::Simple::Subcommand::cget

Synopsis: gets the package options.

Details: see section 4.1.

2.4.2 ::Simple::Subcommand::configure

Synopsis: configures the package options.

Details: see section 4.2.

2.4.3 proc-sub procedure arguments body

Synopsis: creates a subcommand procedure.

Details: see section 4.3.

2.4.4 ::Simple::Subcommand::delete procedure

Synopsis: deletes a subcommand procedure.

Details: see section 4.4.

2.4.5 ::Simple::Subcommand::information exists command

Synopsis: returns whether a procedure is a base command procedure.

Details: see section 4.5.

2.4.6 ::Simple::Subcommand::information subcommands command

Synopsis: returns a base command procedure subcommand list.

Details: see section 4.6.

2.4.7 ::Simple::Subcommand::move sourceProcedure targetProcedure

Synopsis: renames a subcommand procedure.

Details: see section 4.7.

2.5 Errors

2.5.1 ::Simple::Subcommand::CANT-CREATE

Message: can't create subcommand "command subcommand": procedure "command" already exists.

Explanation: the subcommand procedure "command subcommand" could not be created because a procedure named as the subcommand base command (command) already exists.

Corrective action: either delete that procedure or choose another name for the subcommand base command.

2.5.2 ::Simple::Subcommand::CANT-DELETE-OR-RENAME

Message: can't delete or rename "procedure": command doesn't exist.

Explanation: the procedure "procedure" could not be delete or renamed because it does not exist.

2.5.3 ::Simple::Subcommand::NON-EXISTING-COMMAND

Message: "command" isn't a subcommand base command procedure.

Explanation: the subcommand list could not be retrieved because command is not a subcommand base command procedure. Either it is a regular procedure, a subcommand procedure or does not exist.

3. Package further information

3.1 Details

4. Package command details

4.1 ::Simple::Subcommand::cget

4.1.1 Command description

Synopsis: gets the package options.

Access mode: public.

4.1.2 Command public API

Arguments: none.

Returns: the requested option value or the whole list of options if none specified.

4.2 ::Simple::Subcommand::configure

4.2.1 Command description

Synopsis: configures the package options.

Access mode: public.

4.2.2 Command public API

Arguments: none.

Returns: the "package with no options" error is thrown.

4.3 proc-sub procedure arguments body

(Alias for ::Simple::Subcommand::create).

4.3.1 Command description

Synopsis: creates a subcommand procedure.

Access mode: public.

Keywords: procedure, command, subcommand, family, composite and ensemble.

4.3.1.1 Overview

This procedure acts as an interface to the proc command to create subcommand procedures. Such subcommand procedures behave similarly to Tcl subcommands (such as string or array) in terms of error handling: if the base command is invoked with an incorrect subcommand, an error is thrown informing of the allowed subcommands; also, when a subcommand is called with a bad number of arguments, an error is thrown informing of the argument list for that subcommand.

The syntax for the argument list is identical to that accepted by the proc command.

4.3.1.2 Examples

4.3.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Base command and subcommand pair
arguments canonicalarg-list (n/a) Subcommand procedure argument list
body script (n/a) Subcommand procedure body

Returns: the empty string.

Effects:

4.3.3 Command further information

4.3.3.1 Details

A base command is created with the given base command name. The base command body simply calls the ::Simple::Subcommand::Priv::base-command procedure passing all arguments received. The actual subcommand procedure is then created with the name command subcommand where command is the base command name and subcommand is the subcommand name.

4.3.3.2 References

4.4 ::Simple::Subcommand::delete procedure

4.4.1 Command description

Synopsis: deletes a subcommand procedure.

Access mode: public.

4.4.1.1 Overview

This command is similar to the rename command when its second argument is empty, but works for subcommand procedures only.

4.4.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Base command and subcommand pair

Returns: the empty string.

Effects:

4.4.3 Command further information

4.4.3.1 Details

4.5 ::Simple::Subcommand::information exists command

4.5.1 Command description

Synopsis: returns whether a procedure is a base command procedure.

Access mode: public.

4.5.2 Command public API

Arguments:

Argument Type Default value/ choices Description
command name (n/a) Base command name

Returns: whether the procedure is a base command procedure.

4.5.3 Command further information

4.5.3.1 Details

4.5.3.2 References

4.6 ::Simple::Subcommand::information subcommands command

4.6.1 Command description

Synopsis: returns a base command procedure subcommand list.

Access mode: public.

4.6.2 Command public API

Arguments:

Argument Type Default value/ choices Description
command name (n/a) Base command name

Returns: the base command procedure subcommand list.

4.6.3 Command further information

4.6.3.1 References

4.6.3.2 Remarks

4.7 ::Simple::Subcommand::move sourceProcedure targetProcedure

4.7.1 Command description

Synopsis: renames a subcommand procedure.

Access mode: public.

4.7.1.1 Overview

This command is similar to the rename command when its second argument is non-empty, but works for subcommand procedures only.

4.7.2 Command public API

Arguments:

Argument Type Default value/ choices Description
sourceProcedure name (n/a) Source base command and subcommand pair
targetProcedure name (n/a) Target base command and subcommand pair

Returns: the empty string.

Effects:

4.7.3 Command further information

4.7.3.1 Details

4.7.3.2 Remarks

4.7.3.3 Todo