gong/lib.rs
1// Copyright 2017 Lyndon Brown
2//
3// This file is part of the `gong` command-line argument processing library.
4//
5// Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not
6// copy, modify, or distribute this file except in compliance with said license. You can find copies
7// of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at
8// <http://opensource.org/licenses/MIT> and <http://www.apache.org/licenses/LICENSE-2.0>
9// respectively.
10
11//! A lightweight, flexible and simple-to-use library provided to *assist* in processing command
12//! line arguments.
13//!
14//! Licensed under the MIT license or the Apache license, Version 2.0, at your option.
15//!
16//! # Documentation
17//!
18//! Documentation has been split up into chapters:
19//!
20//! - [Overview](docs/overview/index.html)
21//! - [Options support](docs/options/index.html)
22//! - [Usage](docs/usage/index.html)
23
24#![doc(html_logo_url = "https://github.com/jnqnfe/gong/raw/master/logo.png",
25 html_favicon_url = "https://github.com/jnqnfe/gong/raw/master/favicon.ico")]
26
27pub mod docs;
28#[macro_use]
29mod macros; //Note: If we use these in the lib (e.g. internal tests) then this mod must come first!
30pub mod analysis;
31mod engine;
32pub mod options;
33
34/* -- Deprecated stuff -- */
35/* Note, not possible to use a type for enum aliasing to mark deprecated, have to do without */
36
37// Does marking the `pub use` for re-exporting enums to old location with deprecated work?
38#[deprecated(since = "1.1.0", note = "access from the `analysis` mod")]
39pub use analysis::{ItemClass, Item, ItemE, ItemW, DataLocation};
40#[deprecated(since = "1.1.0", note = "access from the `options` mod")]
41pub use options::{OptionsMode};
42
43#[deprecated(since = "1.1.0", note = "now called `analysis::Analysis`")]
44pub type Results<'a> = analysis::Analysis<'a>;
45#[deprecated(since = "1.1.0", note = "moved to `options::OptionSetEx`")]
46pub type Options<'a> = options::OptionSetEx<'a>;
47#[deprecated(since = "1.1.0", note = "moved to `options::LongOption`")]
48pub type LongOption<'a> = options::LongOption<'a>;
49#[deprecated(since = "1.1.0", note = "moved to `options::ShortOption`")]
50pub type ShortOption = options::ShortOption;
51
52/// Analyses provided program arguments, using provided information about valid available options.
53///
54/// Returns a result set describing the result of the analysis. This may include `&str` references
55/// to strings provided in the `args` and `options` parameter data. Take note of this with respect
56/// to object lifetimes.
57///
58/// Expects available `options` data to have already been validated. (See
59/// [`OptionSetEx::is_valid`](options/struct.OptionSetEx.html#method.is_valid)).
60#[deprecated(since = "1.2.0", note = "use the method on the option set object instead")]
61pub fn process<'o, 'a, A>(args: &'a [A], options: &'o options::OptionSetEx<'a>) -> analysis::Analysis<'a>
62 where A: 'a + std::convert::AsRef<str>,
63 'a: 'o
64{
65 engine::process(args, &options.as_fixed())
66}