All Projects → dalance → structopt-toml

dalance / structopt-toml

Licence: other
An default value loader from TOML for structopt

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to structopt-toml

Caporal.js
A full-featured framework for building command line applications (cli) with node.js
Stars: ✭ 3,279 (+14156.52%)
Mutual labels:  argument-parsing, command-line-parser
declarative-parser
Modern, declarative argument parser for Python 3.6+
Stars: ✭ 31 (+34.78%)
Mutual labels:  argument-parsing, command-line-parser
Clikt
Multiplatform command line interface parsing for Kotlin
Stars: ✭ 1,658 (+7108.7%)
Mutual labels:  argument-parsing, command-line-parser
Picocli
Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
Stars: ✭ 3,286 (+14186.96%)
Mutual labels:  argument-parsing, command-line-parser
Clap
Create your command-line parser, with all of the bells and whistles, declaratively or procedurally.
Stars: ✭ 7,174 (+31091.3%)
Mutual labels:  argument-parsing, command-line-parser
Nclap
NClap is a .NET library for parsing command-line arguments and building interactive command shells. It's driven by a declarative attribute syntax, and easy to extend.
Stars: ✭ 51 (+121.74%)
Mutual labels:  argument-parsing, command-line-parser
Argumentparser
Faster, easier, more declarative parsing of command line arguments in Objective-C/Foundation.
Stars: ✭ 251 (+991.3%)
Mutual labels:  argument-parsing, command-line-parser
jbock
Reflectionless command line parser
Stars: ✭ 73 (+217.39%)
Mutual labels:  command-line-parser
argparser
Simple command-line parser for C/C++ programs
Stars: ✭ 50 (+117.39%)
Mutual labels:  command-line-parser
config-cpp
C++ Configuration management library inspired by the Viper package for golang.
Stars: ✭ 21 (-8.7%)
Mutual labels:  command-line-parser
opzioni
The wanna-be-simplest command line arguments library for C++
Stars: ✭ 29 (+26.09%)
Mutual labels:  command-line-parser
opster
Command line parsing speedster
Stars: ✭ 52 (+126.09%)
Mutual labels:  command-line-parser
dropt
dropt is yet another C library for parsing command-line options.
Stars: ✭ 39 (+69.57%)
Mutual labels:  command-line-parser
CommandLineParser.Core
💻 A simple, light-weight and strongly typed Command Line Parser made in .NET Standard!
Stars: ✭ 32 (+39.13%)
Mutual labels:  command-line-parser
Utility.CommandLine.Arguments
A C# .NET class library containing tools for parsing the command line arguments of console applications.
Stars: ✭ 105 (+356.52%)
Mutual labels:  command-line-parser
option-parser
A Lightweight, header-only CLI option parser for C++
Stars: ✭ 16 (-30.43%)
Mutual labels:  command-line-parser
CmdLine2
Command line argument parser (C++14)
Stars: ✭ 18 (-21.74%)
Mutual labels:  command-line-parser
args
Simple and type-safe commandline argument parser for C++14
Stars: ✭ 63 (+173.91%)
Mutual labels:  command-line-parser
Comonicon.jl
Your best CLI generator in JuliaLang
Stars: ✭ 181 (+686.96%)
Mutual labels:  command-line-parser
discord-message-handler
Message and command handler for discord.js bots and applications
Stars: ✭ 19 (-17.39%)
Mutual labels:  command-line-parser

structopt-toml

An default value loader from TOML for structopt. It combinates with structopt.

Actions Status Crates.io Docs.rs codecov

Usage

This crate must be used with serde, serde_derive, structopt, and toml explicitly.

[dependencies]
serde          = "1.0.104"
serde_derive   = "1.0.104"
structopt      = "0.3.11"
structopt-toml = "0.5.0"
toml           = "0.5.6"

Example

If derive(Deserialize), derive(StructOptToml) and serde(default) are added to the struct with derive(StructOpt), some functions like from_args_with_toml can be used.

use serde_derive::Deserialize;
use structopt::StructOpt;
use structopt_toml::StructOptToml;

#[derive(Debug, Deserialize, StructOpt, StructOptToml)]
#[serde(default)]
struct Opt {
    #[structopt(default_value = "0", short = "a")] a: i32,
    #[structopt(default_value = "0", short = "b")] b: i32,
}

fn main() {
    let toml_str = r#"
        a = 10
    "#;
    let opt = Opt::from_args_with_toml(toml_str).expect("toml parse failed");
    println!("a:{}", opt.a);
    println!("b:{}", opt.b);
}

The execution result is below.

$ ./example
a:10        // value from TOML string
b:0         // value from default_value of structopt

$ ./example -a 20
a:20        // value from command line argument
b:0

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].