easy_argv

Crates.ioeasy_argv
lib.rseasy_argv
version0.1.2
sourcesrc
created_at2024-04-29 19:19:30.813402
updated_at2024-04-29 19:26:10.320118
descriptionProvides a helper for pulling and converting arguments, flags, and value overrides from a command statement.
homepage
repository
max_upload_size
id1224436
size17,235
(m-rgans)

documentation

README

Easy Argv

Purpose

Easy Argv is a helper library for interpreting command line input, whether from the shell or in an interactive console application.
It has the ability to automatically convert arguments to a target data type using either the FromStr trait or a helper object if more information that just the string itself is required to transform the string into the desired type.

Usage

Instantiation

Usage of the library is primarily through the ArgVector struct. It can be instanced using from_str on the input that is to be parsed.

Basic Usage

The basic ArgVector struct is used for operating on the whole line. It can be used to retrieve flags, arguments, and value overrides.

Value Overrides

A value override is any statement which follows the form of key=value. A value override may have the flag prefix in front of it, which will set the flag for key.

Conversion Helpers

Sometimes a string alone is not enough to convert an argument to its associated data type. For example, the arguments may correspond to entries in a hashmap. For these cases, the converter trait is used. The functions which use converters follow the form of get_x_converter where x is either single or many.

Argument iterator

The argument iterator is meant to be used to retrieve arguments in order that they were provided. Each argument that is successfully extracted from the iterator will move its index forward until there are no more arguments. This allows the user to, say, extract one or more integers, followed by a device name, then a float value, and so on.
Flags and value overrides can be retrieved from the iterator at any time. Since the iterator does not need to borrow mutably, args relative to the current position can be obtained using an offset with get_index()

Examples

todo

Commit count: 0

cargo fmt