Most intuitive global cli maker. *(lazy_static + config-rs + clap)

Overview

argone


Most intuitive global cli maker. *(lazy_static + config-rs + clap)

CI Crates.io Licensed Twitter

| Examples | Docs | Latest Note |

[dependencies]
argone = "0.5"

Phases

  1. Parsing clap.
  2. If clap-argument is None
    and the argument has [Config] mark
    then extract data from Config(file or env).
  3. When the data is extracted and that was empty,
    eventually set Default(=) value.

Example

* basics
use argone::{prelude::*, *};

ARGONE! {

    version = "0.1"
    author = "just-do-halee <[email protected]>"
    about = "this is our application"

    Config {
        // file's extension could be
        // ini | json | json5 | yaml | toml | ron
        file = "examples/Config"
        // arg's env-prefix ex:) APP_...
        prefix = "APP"
    }

    Args {

        /// This is just one required argument.
        /// and three slashes will be an 'about' for clap cli.
        name: String

        /// This argument is connected to Config(file or env).
        /// Template is
        /// [Config] $name: Option<$type> = Some($default_value) or
        /// [Config] $name: Vec<$type> = vec![$default_values]
        /// and this works in non-required argument.
        [Config] age: Option<u8> = Some(12),
        [Config] job: Vec<String>

        // And all arugments are working on clap_derive format.

        /// Exactly same with clap_derive.
        (short, long)
        parents: Vec<String>

        /// But (default_value = "..") doesn't work to
        /// the config arguments. instead, this would work.
        (short, long, name = "WEIGHT")
        [Config] weight: Option<u8> = Some(50)

        /// In normal arguments, default_value will work.
        (short, long, default_value = "1")
        verbose: u8

    }

    commands = Sub

}

COMMANDS! {
    Sub {

        /// The subcommand
        /// but subcommands do not have config arguments.
        First {
            version = "1.0"
            author = "just-do-halee <[email protected]>"
            Args {
                /// This area is also same.
                test: String
            }
        }

        Second {
            about = "The second subcommand"
            Args {
                test: u8
            }
        }

    }
}

fn main() {
    println!("{:#?}", *ARGS);

    if ARGS.name == "test" {
        println!("name is test.");
    }

    if ARGS.age.unwrap() != 12 {
        println!("age is not matching default 12.");
    }

    for job in &ARGS.job {
        println!("job: {}", job);
    }

    for parents in &ARGS.parents {
        println!("parent: {}", parents);
    }

    println!(
        "weight is {}\nverbose is {}",
        ARGS.weight.unwrap(),
        ARGS.verbose
    );

    if let Some(sub) = &ARGS.commands {
        match sub {
            Sub::First { test } => println!("first command: {}", test),
            Sub::Second { test } => println!("second command: {}", test),
        }
    } else {
        println!("none subcommands");
    }
}
You might also like...
Intuitive GTK4/LibAdwaita music player
Intuitive GTK4/LibAdwaita music player

Resonance Harmonize your listening experience with Resonance. Resonance is an intuitive music player application written in Rust & Python, with a clea

A more compact and intuitive ASCII table in your terminal: an alternative to
A more compact and intuitive ASCII table in your terminal: an alternative to "man 7 ascii" and "ascii"

asciit A more compact and intuitive ASCII table in your terminal: an alternative to man 7 ascii and ascii. Colored numbers and letters are much more e

Advent of Code 2023 solutions - #15 on global leaderboard

My solutions for Advent of Code 2023, written in Rust. The code requires Rust nightly to run. Sample inputs from each day are provided. To run with ac

Fully-typed global state management with a topics subscription system for Dioxus 🧬

dioxus-radio 📡🦀 ⚠️ Work in progress !! ⚠️ . Fully-typed global state management with a topics subscription system for Dioxus 🧬. Who is this for You

The dead easy way to use config files in your rust project

Configr The dead easy way to use config files in your project This will load a config.toml file if it exists, otherwise it will create the needed fold

FastSSH is a TUI that allows you to quickly connect to your services by navigating through your SSH config.
FastSSH is a TUI that allows you to quickly connect to your services by navigating through your SSH config.

Connect quickly to your services 🚀 FastSSH is a TUI that allows you to quickly connect to your services by navigating through your SSH config. Instal

Irx-config - The library provides convenient way to represent/parse configuration from different sources

The irx-config library provides convenient way to represent/parse configuration from different sources. The main goals is to be very easy to use and t

⚙️ A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more.
⚙️ A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more.

This repository lists static analysis tools for all programming languages, build tools, config files and more. The official website, analysis-tools.de

🕺 Run React code snippets/components from your command-line without config

Run React code snippets/components from your command-line without config.

Comments
  • basic example does not compile

    basic example does not compile

    Cargo's output:

       Compiling testing-argone v0.1.0 (/path/testing-argone)
    error: cannot find derive macro `Parser` in this scope
      --> src/main.rs:32:1
       |
    32 | / ARGONE! {
    33 | |
    34 | |     version = "0.1"
    35 | |     author = "just-do-halee <[email protected]>"
    ...  |
    78 | |
    79 | | }
       | |_^
       |
    note: `Parser` is imported here, but it is only a trait, without a derive macro
      --> src/main.rs:30:14
       |
    30 | use argone::{prelude::*, *};
       |              ^^^^^^^^^^
       = note: this error originates in the macro `ARGONE` (in Nightly builds, run with -Z macro-backtrace for more info)
    
    error: cannot find attribute `clap` in this scope
      --> src/main.rs:32:1
       |
    32 | / ARGONE! {
    33 | |
    34 | |     version = "0.1"
    35 | |     author = "just-do-halee <[email protected]>"
    ...  |
    78 | |
    79 | | }
       | |_^
       |
    note: `clap` is imported here, but it is a crate, not an attribute
      --> src/main.rs:30:14
       |
    30 | use argone::{prelude::*, *};
       |              ^^^^^^^^^^
       = note: this error originates in the macro `ARGONE` (in Nightly builds, run with -Z macro-backtrace for more info)
    
    error: cannot find derive macro `Parser` in this scope
       --> src/main.rs:81:1
        |
    81  | / COMMANDS! {
    82  | |     Sub {
    83  | |
    84  | |         /// The subcommand
    ...   |
    102 | |     }
    103 | | }
        | |_^
        |
    note: `Parser` is imported here, but it is only a trait, without a derive macro
       --> src/main.rs:30:14
        |
    30  | use argone::{prelude::*, *};
        |              ^^^^^^^^^^
        = note: this error originates in the macro `COMMANDS` (in Nightly builds, run with -Z macro-backtrace for more info)
    
    error: cannot find attribute `clap` in this scope
       --> src/main.rs:81:1
        |
    81  | / COMMANDS! {
    82  | |     Sub {
    83  | |
    84  | |         /// The subcommand
    ...   |
    102 | |     }
    103 | | }
        | |_^
        |
    note: `clap` is imported here, but it is a crate, not an attribute
       --> src/main.rs:30:14
        |
    30  | use argone::{prelude::*, *};
        |              ^^^^^^^^^^
        = note: this error originates in the macro `COMMANDS` (in Nightly builds, run with -Z macro-backtrace for more info)
    
    error[E0599]: no function or associated item named `parse` found for struct `Args` in the current scope
      --> src/main.rs:32:1
       |
    32 | / ARGONE! {
    33 | |
    34 | |     version = "0.1"
    35 | |     author = "just-do-halee <[email protected]>"
    ...  |
    78 | |
    79 | | }
       | | ^
       | | |
       | |_function or associated item `parse` not found for this
       |   function or associated item not found in `Args`
       |
       = help: items from traits can only be used if the trait is implemented and in scope
       = note: the following traits define an item `parse`, perhaps you need to implement one of them:
               candidate #1: `StructOpt`
               candidate #2: `nom::sequence::Tuple`
       = note: this error originates in the macro `ARGONE` (in Nightly builds, run with -Z macro-backtrace for more info)
    
    For more information about this error, try `rustc --explain E0599`.
    error: could not compile `testing-argone` due to 7 previous errors
    

    The Cargo.toml contains argone = 0.5.

    opened by UnlimitedCookies 1
Releases(v0.5.2)
Owner
Doha Lee
I will change the world.
Doha Lee
Grid-based drum sequencer plugin as MIDI FX in CLAP/VST3 format

dr-seq Grid-based drum sequencer plugin as MIDI FX in CLAP/VST3 format. WARNING: This project is in a very early state. So there is no guarantee for a

Oliver Rockstedt 6 Jan 29, 2023
Intuitive find & replace CLI (sed alternative)

sd - s[earch] & d[isplace] sd is an intuitive find & replace CLI. The Pitch Why use it over any existing tools? Painless regular expressions sd uses r

Gregory 4k Jan 4, 2023
🐙 Loads config and hosts for gh CLI in Rust.

gh-config-rs Loads config and hosts for gh CLI in Rust. Getting started [dependencies] gh-config = "0.2" Usage use std::error::Error; use gh_config::*

Naoki Ikeguchi 2 Jul 23, 2022
A CLI utility installed as "ansi" to quickly get ANSI escape sequences. Supports the most basic ones, like colors and styles as bold or italic.

'ansi' - a CLI utility to quickly get ANSI escape codes This Rust project called ansi-escape-sequences-cli provides an executable called ansi which ca

Philipp Schuster 5 Jul 28, 2022
A CLI app that exposes most of the h3o API for scripting.

h3o-cli — A CLI app exposing the h3o API for scripting How to install Pre-compiled binaries You can download a pre-compiled executable for Linux, MacO

Hydronium Labs 5 Jan 10, 2023
du + rust = dust. Like du but more intuitive.

Dust du + rust = dust. Like du but more intuitive. Why Because I want an easy way to see where my disk is being used. Demo Install Cargo cargo install

andy.boot 5.4k Jan 4, 2023
A more intuitive version of du in rust

A more intuitive version of du in rust

andy.boot 3k Sep 20, 2021
global state management for dioxus built on the concept of atoms. currently under 🏗

Fermi: A global state management solution for Dioxus, inspired by Recoil.Js Fermi provides primitives for managing global state in Dioxus applications

Dioxus 15 Feb 12, 2022
🚀 A blazingly fast easy to use dotfile and global theme manager written in Rust

GTHEME A blazingly fast easy to use dotfile and global theme manager for *NIX systems written in Rust ?? Demo using wip desktop. To check out more des

David Rodriguez 19 Nov 28, 2022
The intuitive command-line file uploader.

☁️ upl The intuitive command-line file uploader. ??️ Features (roadmap) Upload files via the command-line Sane built-in upload destinations Configurat

null 4 Oct 13, 2022