GNU
|
Liberty Eiffel
|
Automated Tests
|
Wiki
|
Savannah project
|
Debian packages
|
Documentation
>
libraries
>
CLARG_CUSTOMS
+
Point of view
All features
ANY
CLARG_PARSER
All features
class CLARG_CUSTOMS [D_]
Summary
top
Direct parents
Inherit list:
CLARG_WITH_ARGS
Class invariant
top
decode
/= Void
set /= Void
short /= Void implies short.count = 1
is_optional or else is_positional or else is_mandatory
Overview
top
Creation features
{
COMMAND_LINE_ARGUMENT_FACTORY
}
optional
(a_short:
ABSTRACT_STRING
, a_long:
ABSTRACT_STRING
, a_name:
ABSTRACT_STRING
, a_usage:
ABSTRACT_STRING
, a_validate:
FUNCTION
[
TUPLE 1
[
STRING
],
BOOLEAN
], a_decode:
FUNCTION
[
TUPLE
[TUPLE 1[
STRING
], D_]])
positional
(a_name:
ABSTRACT_STRING
, a_usage:
ABSTRACT_STRING
, a_validate:
FUNCTION
[
TUPLE 1
[
STRING
],
BOOLEAN
], a_decode:
FUNCTION
[
TUPLE
[TUPLE 1[
STRING
], D_]])
Features
{
CLARG_PARSER
}
is_valid_data
(arg:
STRING
):
BOOLEAN
{}
decode_
(arg:
STRING
): D_
{}
optional
(a_short:
ABSTRACT_STRING
, a_long:
ABSTRACT_STRING
, a_name:
ABSTRACT_STRING
, a_usage:
ABSTRACT_STRING
, a_validate:
FUNCTION
[
TUPLE 1
[
STRING
],
BOOLEAN
], a_decode:
FUNCTION
[
TUPLE
[TUPLE 1[
STRING
], D_]])
positional
(a_name:
ABSTRACT_STRING
, a_usage:
ABSTRACT_STRING
, a_validate:
FUNCTION
[
TUPLE 1
[
STRING
],
BOOLEAN
], a_decode:
FUNCTION
[
TUPLE
[TUPLE 1[
STRING
], D_]])
validate
:
FUNCTION
[
TUPLE 1
[
STRING
],
BOOLEAN
]
decode
:
FUNCTION
[
TUPLE
[TUPLE 1[
STRING
], D_]]
{
ANY
}
items
: TRAVERSABLE[E_]
The argument value, if
is_set
is_repeatable
:
BOOLEAN
True if the argument is repeatable; False if unique.
is_set
:
BOOLEAN
True if the option is present and correct.
{
COMMAND_LINE_ARGUMENTS
,
COMMAND_LINE_ARGUMENT
}
prepare_parse
is_set_at
(context:
COMMAND_LINE_CONTEXT
):
BOOLEAN
True if the option is present and correct at the given context.
undo_parse
(context:
COMMAND_LINE_CONTEXT
)
set_data
(context:
COMMAND_LINE_CONTEXT
, data:
STRING
)
TRAVERSABLE
:
{
ANY
}
count
:
INTEGER_32
Number of available items in the hoard.
is_empty
:
BOOLEAN
Is the hoard empty ?
See also
count
.
lower
:
INTEGER_32
Minimum index.
upper
:
INTEGER_32
Maximum index.
item
(i:
INTEGER_32
): E_
Item at the corresponding index
i
.
first
: E_
The very
first
item.
last
: E_
The
last
item.
new_iterator
: ITERATOR[E_]
{}
set
: AVL_DICTIONARY[E_,
COMMAND_LINE_CONTEXT
]
{
ANY
}
enumerate
: ENUMERATE[E_]
Other features:
{
ANY
}
get_new_iterator
: ITERATOR[E_]
Agent-based features:
{
ANY
}
for_each
(action:
PROCEDURE
[
TUPLE
[TUPLE 1[E_]]])
Apply
action
to every item of
Current
.
for_all
(test:
FUNCTION
[
TUPLE
[TUPLE 1[E_]]]):
BOOLEAN
Do all items satisfy
test
?
exists
(test:
FUNCTION
[
TUPLE
[TUPLE 1[E_]]]):
BOOLEAN
Does at least one item satisfy
test
?
aggregate
(action:
FUNCTION
[
TUPLE
[TUPLE 2[E_, E_], E_]], initial: E_): E_
Aggregate all the elements starting from the initial value.
Printing:
{
ANY
}
out_in_tagged_out_memory
Append terse printable representation of current object in
tagged_out_memory
.
{
ANY
}
generation
:
INTEGER_32
{}
next_generation
Agent-based features:
{
ANY
}
do_all
(action:
ROUTINE
[
TUPLE
[TUPLE 1[E_]]])
Apply
action
to every item of
Current
.
{}
_inline_agent1
(a:
ROUTINE
[
TUPLE
[TUPLE 1[E_]]], e: E_)
Indexing:
{
ANY
}
valid_index
(i:
INTEGER_32
):
BOOLEAN
True when
i
is valid (i.e., inside actual bounds).
{
ANY
}
as_mandatory
: CLARG_CUSTOMS [D_]
Make the option mandatory (default for positionals)
prefix "+"
: CLARG_CUSTOMS [D_]
Make the option mandatory (default for positionals)
as_optional
: CLARG_CUSTOMS [D_]
Make the option optional (default for options)
prefix "-"
: CLARG_CUSTOMS [D_]
Make the option optional (default for options)
{
ANY
}
is_mandatory
:
BOOLEAN
True if the argument must be set at least once.
is_optional
:
BOOLEAN
True if the argument may not be set.
is_positional
:
BOOLEAN
True if the argument is not introduced by a flag.
can_be_mandatory
:
BOOLEAN
True if the argument can be
set_mandatory
(True).
can_be_optional
:
BOOLEAN
True if the argument can be
set_mandatory
(False).
{
ANY
}
short
:
FIXED_STRING
The short (one-letter) option flag introducing the argument, Void for positionals
long
:
FIXED_STRING
The long option flag introducing the argument, Void for positionals
usage
:
FIXED_STRING
The option usage
force_index
(a_index:
INTEGER_32
)
Force a positional parameter to be valid only at the given index
{
COMMAND_LINE_ARGUMENTS
,
COMMAND_LINE_ARGUMENT
}
set_mandatory
(parent_option: CLARG_CUSTOMS [D_], enable:
BOOLEAN
)
{}
parent
: CLARG_CUSTOMS [D_]
Internal technical trick to ensure that arguments with a non-standard behaviour (
set_mandatory
) are correctly managed.
{
ANY
}
infix "or"
(other:
COMMAND_LINE_ARGUMENT
):
COMMAND_LINE_ARGUMENT
Arguments disjunction.
infix "or else"
(other:
COMMAND_LINE_ARGUMENT
):
COMMAND_LINE_ARGUMENT
Arguments disjunction.
infix "and"
(other:
COMMAND_LINE_ARGUMENT
):
COMMAND_LINE_ARGUMENT
Arguments conjunction.
infix "and then"
(other:
COMMAND_LINE_ARGUMENT
):
COMMAND_LINE_ARGUMENT
Arguments conjunction.
prefix "not"
:
COMMAND_LINE_ARGUMENT
(tentative; don't use it, the semantics is not well defined)
{
COMMAND_LINE_ARGUMENTS
,
COMMAND_LINE_ARGUMENT
}
parse_command_line
(context:
COMMAND_LINE_CONTEXT
):
COMMAND_LINE_CONTEXT
usage_summary
(stream:
OUTPUT_STREAM
)
usage_details
(stream:
OUTPUT_STREAM
)
{}
detailed
:
BOOLEAN
{
ANY
}
name
:
FIXED_STRING
index
:
INTEGER_32
parsing
{}
parse_positional
(context:
COMMAND_LINE_CONTEXT
):
COMMAND_LINE_CONTEXT
parse_short
(context:
COMMAND_LINE_CONTEXT
):
COMMAND_LINE_CONTEXT
parse_long
(context:
COMMAND_LINE_CONTEXT
):
COMMAND_LINE_CONTEXT
{
CLARG_PARSER
}
set_data_
(context:
COMMAND_LINE_CONTEXT
, data:
STRING
)
{
ANY
}
argument_count
:
INTEGER_32
Number of arguments given to command that started system execution (command name does not count).
argument
(i:
INTEGER_32
):
STRING
i
th argument of command that started system execution Gives the command name if
i
is 0.
command_name
:
STRING
{}
command_arguments
:
FAST_ARRAY
[
STRING
]
Give access to arguments command line including the command name at index 0.
Implementation of
ARGUMENTS
(do not use directly):
{}
se_argc
:
INTEGER_32
To implement
command_arguments
se_argv
(i:
INTEGER_32
):
STRING
To implement
command_arguments
patterns
{}
short_pattern
:
REGULAR_EXPRESSION
long_pattern
:
REGULAR_EXPRESSION
long_equal_pattern
:
REGULAR_EXPRESSION
queries
{}
is_short
(arg:
STRING
, a_index:
INTEGER_32
):
BOOLEAN
is_long
(arg:
STRING
):
BOOLEAN
is_long_equal
(arg:
STRING
):
BOOLEAN
usage output helpers
{}
put_short
(stream:
OUTPUT_STREAM
)
put_long
(stream:
OUTPUT_STREAM
)
is_valid_data
(arg:
STRING
):
BOOLEAN
effective function
{
CLARG_PARSER
}
top
decode_
(arg:
STRING
): D_
effective function
{}
top
require
is_valid_data(arg)
optional
(a_short:
ABSTRACT_STRING
, a_long:
ABSTRACT_STRING
, a_name:
ABSTRACT_STRING
, a_usage:
ABSTRACT_STRING
, a_validate:
FUNCTION
[
TUPLE 1
[
STRING
],
BOOLEAN
], a_decode:
FUNCTION
[
TUPLE
[TUPLE 1[
STRING
], D_]])
effective procedure
{}
top
require
a_short /= Void implies a_short.count = 1
a_short /= Void or else a_long /= Void
a_name /= Void
a_decode /= Void
ensure
is_optional
a_short /= Void implies
short
.is_equal(a_short)
a_long /= Void implies
long
.is_equal(a_long)
name
.is_equal(a_name)
a_usage /= Void implies
usage
.is_equal(a_usage)
validate
= a_validate
decode
= a_decode
positional
(a_name:
ABSTRACT_STRING
, a_usage:
ABSTRACT_STRING
, a_validate:
FUNCTION
[
TUPLE 1
[
STRING
],
BOOLEAN
], a_decode:
FUNCTION
[
TUPLE
[TUPLE 1[
STRING
], D_]])
effective procedure
{}
top
require
a_name /= Void
a_decode /= Void
ensure
is_positional
name
.is_equal(a_name)
a_usage /= Void implies
usage
.is_equal(a_usage)
validate
= a_validate
decode
= a_decode
validate
:
FUNCTION
[
TUPLE 1
[
STRING
],
BOOLEAN
]
writable attribute
{}
top
decode
:
FUNCTION
[
TUPLE
[TUPLE 1[
STRING
], D_]]
writable attribute
{}
top
items
: TRAVERSABLE[E_]
effective function
{
ANY
}
top
The argument value, if
is_set
is_repeatable
:
BOOLEAN
is True
constant attribute
{
ANY
}
top
True if the argument is repeatable; False if unique.
is_set
:
BOOLEAN
effective function
{
ANY
}
top
True if the option is present and correct.
prepare_parse
effective procedure
{
COMMAND_LINE_ARGUMENTS
,
COMMAND_LINE_ARGUMENT
}
top
ensure
not is_set
is_set_at
(context:
COMMAND_LINE_CONTEXT
):
BOOLEAN
effective function
{
COMMAND_LINE_ARGUMENTS
,
COMMAND_LINE_ARGUMENT
}
top
True if the option is present and correct at the given context.
require
context.is_parsed
ensure
Result implies is_set
not is_repeatable implies Result = is_set
undo_parse
(context:
COMMAND_LINE_CONTEXT
)
effective procedure
{
COMMAND_LINE_ARGUMENTS
,
COMMAND_LINE_ARGUMENT
}
top
require
is_set_at(context)
ensure
not is_set_at(context)
not is_repeatable implies not is_set
set_data
(context:
COMMAND_LINE_CONTEXT
, data:
STRING
)
effective procedure
{
COMMAND_LINE_ARGUMENTS
,
COMMAND_LINE_ARGUMENT
}
top
require
is_valid_data(data)
ensure
is_set_at(context)
count
:
INTEGER_32
effective function
{
ANY
}
top
Number of available items in the hoard.
See also
is_empty
ensure
Result >= 0
is_empty
:
BOOLEAN
effective function
{
ANY
}
top
Is the hoard empty ?
See also
count
.
ensure
definition:
Result = count = 0
lower
:
INTEGER_32
effective function
{
ANY
}
top
Minimum index.
See also
upper
,
valid_index
,
item
.
upper
:
INTEGER_32
effective function
{
ANY
}
top
Maximum index.
See also
lower
,
valid_index
,
item
.
item
(i:
INTEGER_32
): E_
effective function
{
ANY
}
top
Item at the corresponding index
i
.
See also
lower
,
upper
,
valid_index
.
require
valid_index(i)
first
: E_
effective function
{
ANY
}
top
The very
first
item.
See also
last
,
item
.
require
not is_empty
ensure
definition:
Result = item(lower)
last
: E_
effective function
{
ANY
}
top
The
last
item.
See also
first
,
item
.
require
not is_empty
ensure
definition:
Result = item(upper)
new_iterator
: ITERATOR[E_]
effective function
{
ANY
}
top
ensure
Result /= Void
Result.generation = generation
set
: AVL_DICTIONARY[E_,
COMMAND_LINE_CONTEXT
]
writable attribute
{}
top
enumerate
: ENUMERATE[E_]
effective function
{
ANY
}
top
get_new_iterator
: ITERATOR[E_]
frozen
effective function
{
ANY
}
top
This feature is obsolete:
Use `new_iterator' instead. This historical SmartEiffel feature is badly named.
for_each
(action:
PROCEDURE
[
TUPLE
[TUPLE 1[E_]]])
effective procedure
{
ANY
}
top
Apply
action
to every item of
Current
.
See also
for_all
,
exists
,
aggregate
.
require
action /= Void
for_all
(test:
FUNCTION
[
TUPLE
[TUPLE 1[E_]]]):
BOOLEAN
effective function
{
ANY
}
top
Do all items satisfy
test
?
See also
for_each
,
exists
,
aggregate
.
require
test /= Void
exists
(test:
FUNCTION
[
TUPLE
[TUPLE 1[E_]]]):
BOOLEAN
effective function
{
ANY
}
top
Does at least one item satisfy
test
?
See also
for_each
,
for_all
,
aggregate
.
require
test /= Void
aggregate
(action:
FUNCTION
[
TUPLE
[TUPLE 2[E_, E_], E_]], initial: E_): E_
effective function
{
ANY
}
top
Aggregate all the elements starting from the initial value.
See also
for_each
,
for_all
,
exists
.
require
action /= Void
out_in_tagged_out_memory
effective procedure
{
ANY
}
top
Append terse printable representation of current object in
tagged_out_memory
.
require
locked:
tagged_out_locked
ensure
still_locked:
tagged_out_locked
not_cleared:
tagged_out_memory.count >= old tagged_out_memory.count
append_only:
old tagged_out_memory.twin.is_equal(tagged_out_memory.substring(1, old tagged_out_memory.count))
generation
:
INTEGER_32
writable attribute
{
ANY
}
top
next_generation
effective procedure
{}
top
ensure
generation
> old
generation
do_all
(action:
ROUTINE
[
TUPLE
[TUPLE 1[E_]]])
frozen
effective procedure
{
ANY
}
top
Apply
action
to every item of
Current
.
This feature is obsolete:
Use `for_each` instead. This feature is not secure because it accepts a FUNCTION, the result of which is lost.
_inline_agent1
(a:
ROUTINE
[
TUPLE
[TUPLE 1[E_]]], e: E_)
frozen
effective procedure
{}
top
valid_index
(i:
INTEGER_32
):
BOOLEAN
effective function
{
ANY
}
top
True when
i
is valid (i.e., inside actual bounds).
See also
lower
,
upper
,
item
.
ensure
definition:
Result =
lower
<= i and i <=
upper
as_mandatory
: CLARG_CUSTOMS [D_]
effective function
{
ANY
}
top
Make the option mandatory (default for positionals)
require
can_be_mandatory
ensure
Result.
is_mandatory
prefix "+"
: CLARG_CUSTOMS [D_]
effective function
{
ANY
}
top
Make the option mandatory (default for positionals)
require
can_be_mandatory
ensure
Result.
is_mandatory
as_optional
: CLARG_CUSTOMS [D_]
effective function
{
ANY
}
top
Make the option optional (default for options)
require
can_be_optional
ensure
not Result.
is_mandatory
prefix "-"
: CLARG_CUSTOMS [D_]
effective function
{
ANY
}
top
Make the option optional (default for options)
require
can_be_optional
ensure
not Result.
is_mandatory
is_mandatory
:
BOOLEAN
deferred function
{
ANY
}
top
True if the argument must be set at least once.
ensure
Result implies
can_be_mandatory
is_optional
:
BOOLEAN
deferred function
{
ANY
}
top
True if the argument may not be set.
ensure
Result implies not
is_positional
is_mandatory
implies not Result
Result implies
can_be_optional
is_positional
:
BOOLEAN
deferred function
{
ANY
}
top
True if the argument is not introduced by a flag.
Such an argument is mandatory and may have an explicit position on the command line (see
force_index
).
ensure
Result implies not
is_optional
Result implies
is_mandatory
can_be_mandatory
:
BOOLEAN
deferred function
{
ANY
}
top
True if the argument can be
set_mandatory
(True).
can_be_optional
:
BOOLEAN
deferred function
{
ANY
}
top
True if the argument can be
set_mandatory
(False).
short
:
FIXED_STRING
deferred function
{
ANY
}
top
The short (one-letter) option flag introducing the argument, Void for positionals
ensure
is_positional
implies Result = Void
Result /= Void implies Result.count = 1
long
:
FIXED_STRING
deferred function
{
ANY
}
top
The long option flag introducing the argument, Void for positionals
ensure
is_positional
implies Result = Void
Result /= Void implies not Result.is_empty
usage
:
FIXED_STRING
deferred function
{
ANY
}
top
The option usage
force_index
(a_index:
INTEGER_32
)
deferred procedure
{
ANY
}
top
Force a positional parameter to be valid only at the given index
require
a_index > 0
is_positional
not
is_repeatable
set_mandatory
(parent_option: CLARG_CUSTOMS [D_], enable:
BOOLEAN
)
deferred procedure
{
COMMAND_LINE_ARGUMENTS
,
COMMAND_LINE_ARGUMENT
}
top
require
parent_option /= Void
enable /=
is_mandatory
enable implies
can_be_mandatory
not enable implies
can_be_optional
ensure
parent
= parent_option
is_mandatory
= enable
parent
: CLARG_CUSTOMS [D_]
deferred function
{}
top
Internal technical trick to ensure that arguments with a non-standard behaviour (
set_mandatory
) are correctly managed.
infix "or"
(other:
COMMAND_LINE_ARGUMENT
):
COMMAND_LINE_ARGUMENT
effective function
{
ANY
}
top
Arguments disjunction.
Useful to implement mutually exclusive sets of arguments.
require
other /= Void
ensure
Result /= Void
infix "or else"
(other:
COMMAND_LINE_ARGUMENT
):
COMMAND_LINE_ARGUMENT
effective function
{
ANY
}
top
Arguments disjunction.
Useful to implement mutually exclusive sets of arguments.
require
other /= Void
ensure
Result /= Void
infix "and"
(other:
COMMAND_LINE_ARGUMENT
):
COMMAND_LINE_ARGUMENT
effective function
{
ANY
}
top
Arguments conjunction.
All the arguments are checked, in any order.
require
other /= Void
ensure
Result /= Void
infix "and then"
(other:
COMMAND_LINE_ARGUMENT
):
COMMAND_LINE_ARGUMENT
effective function
{
ANY
}
top
Arguments conjunction.
All the arguments are checked, in any order.
require
other /= Void
ensure
Result /= Void
prefix "not"
:
COMMAND_LINE_ARGUMENT
effective function
{
ANY
}
top
(tentative; don't use it, the semantics is not well defined)
ensure
Result /= Void
parse_command_line
(context:
COMMAND_LINE_CONTEXT
):
COMMAND_LINE_CONTEXT
deferred function
{
COMMAND_LINE_ARGUMENTS
,
COMMAND_LINE_ARGUMENT
}
top
require
context.is_parsed
usage_summary
(stream:
OUTPUT_STREAM
)
deferred procedure
{
COMMAND_LINE_ARGUMENTS
,
COMMAND_LINE_ARGUMENT
}
top
ensure
not
detailed
usage_details
(stream:
OUTPUT_STREAM
)
deferred procedure
{
COMMAND_LINE_ARGUMENTS
,
COMMAND_LINE_ARGUMENT
}
top
ensure
detailed
detailed
:
BOOLEAN
deferred function
{}
top
name
:
FIXED_STRING
writable attribute
{
ANY
}
top
index
:
INTEGER_32
writable attribute
{
ANY
}
top
parse_positional
(context:
COMMAND_LINE_CONTEXT
):
COMMAND_LINE_CONTEXT
effective function
{}
top
require
is_positional
parse_short
(context:
COMMAND_LINE_CONTEXT
):
COMMAND_LINE_CONTEXT
effective function
{}
top
require
not
is_positional
short
/= Void
parse_long
(context:
COMMAND_LINE_CONTEXT
):
COMMAND_LINE_CONTEXT
effective function
{}
top
require
not
is_positional
long
/= Void
set_data_
(context:
COMMAND_LINE_CONTEXT
, data:
STRING
)
effective procedure
{
CLARG_PARSER
}
top
require
is_valid_data
(data)
parent
/= Void implies
parent
.
is_valid_data
(data)
argument_count
:
INTEGER_32
effective function
{
ANY
}
top
Number of arguments given to command that started system execution (command name does not count).
ensure
Result >= 0
argument
(i:
INTEGER_32
):
STRING
effective function
{
ANY
}
top
i
th argument of command that started system execution Gives the command name if
i
is 0.
require
i >= 0
i <=
argument_count
ensure
Result /= Void
command_name
:
STRING
effective function
{
ANY
}
top
command_arguments
:
FAST_ARRAY
[
STRING
]
frozen
once function
{}
top
Give access to arguments command line including the command name at index 0.
This is a once function, so you can modify command-line arguments! (NOTE: just be sure not to remove the first argument, although you may change it)
ensure
not Result.is_empty
se_argc
:
INTEGER_32
{}
top
To implement
command_arguments
se_argv
(i:
INTEGER_32
):
STRING
{}
top
To implement
command_arguments
short_pattern
:
REGULAR_EXPRESSION
once function
{}
top
long_pattern
:
REGULAR_EXPRESSION
once function
{}
top
long_equal_pattern
:
REGULAR_EXPRESSION
once function
{}
top
is_short
(arg:
STRING
, a_index:
INTEGER_32
):
BOOLEAN
effective function
{}
top
require
short
/= Void
is_long
(arg:
STRING
):
BOOLEAN
effective function
{}
top
require
long
/= Void
is_long_equal
(arg:
STRING
):
BOOLEAN
effective function
{}
top
require
long
/= Void
ensure
Result implies
long_equal_pattern
.named_group_matched("value")
put_short
(stream:
OUTPUT_STREAM
)
effective procedure
{}
top
require
short
/= Void
put_long
(stream:
OUTPUT_STREAM
)
effective procedure
{}
top
require
long
/= Void