Arguments v0.1.0

Source
The command-line arguments the process was started with.

ArgumentCount

pub func ArgumentCount() -> uint

How many arguments the process was started with, the program itself included. Usually at least one, since the program is passed as the first argument; a parent may pass none at all, and then this is zero. Cannot fail and allocates nothing.

Source

Returns: the argument count

Argument

pub func Argument(index: uint) -> OsStringView?

The argument at index, counting the program as argument zero, or none past the last one. The view borrows storage the process owns for its whole life. Cannot fail and allocates nothing.

Source

Parameters

NameTypeDescription
indexuintthe zero-based position of the argument

Returns: the argument's native units, or none when index is not below ArgumentCount

ArgumentIterator

pub struct ArgumentIterator {
    // private fields
}

A walk over the process's arguments in order, the program first. Copy; each copy walks on its own from where it was copied. Holds only a position, so it allocates nothing.

Source

Methods

Iterate

pub func Iterate(self: &ArgumentIterator) -> ArgumentIterator

The walk itself, so that for argument in Arguments() reads every argument.

Returns: a copy of this walk from its current position

Source

Skip

pub func Skip(
    self: &var ArgumentIterator,
    count: uint
) -> ArgumentIterator

Leaves out the next count arguments, as Skip(1) leaves out the program. Advances the walk and returns it, so the call can be chained in a for header. Cannot fail.

NameTypeDescription
countuinthow many arguments to pass over

Returns: this walk, advanced

Source

Implements Iterator

ArgumentIterator conforms to Iterator.

Next

pub func Next(self: &var ArgumentIterator) -> OsStringView?

The next argument, or none after the last.

Returns: the argument's native units, borrowing storage the process owns for its whole life

Source

Arguments

pub func Arguments() -> ArgumentIterator

Every argument the process was started with, the program first. Cannot fail and allocates nothing. Use Skip(1) on the result, or start a loop at index one, to leave out the program's own name.

Source

Returns: a walk over the arguments