Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

where does this 'all caps LIST-IMPORTS' come from? #61

Open
qknight opened this issue Jun 10, 2024 · 0 comments
Open

where does this 'all caps LIST-IMPORTS' come from? #61

qknight opened this issue Jun 10, 2024 · 0 comments

Comments

@qknight
Copy link

qknight commented Jun 10, 2024

With the source below:

use gumdrop::Options;
use std::{env, fs, process};

#[derive(Debug, Options)]
struct Args {
    #[options(help = "Prints the version", short = "v", long = "version")]
    version: bool,

    #[options(help = "Calls the list_imports function with a filename", short = "l", long = "list-imports")]
    list_imports: Option<String>,

    #[options(help = "Updates DLL bindings for <from> so it points to <to>", short = "s", long = "set-import")]
    set_import: bool,

    #[options(free)]
    free_args: Vec<String>,

    #[options(help = "Print this help message and exit", short = "h")]
    help: bool,
}

fn main() {
    let args = Args::parse_args_default_or_exit();

    if args.help {
        println!("{}", Args::usage());
        return;
    }

    if args.version {
        println!("fixPath version 1.0"); // FIXME read from cargo.toml
    } else if let Some(filename) = args.list_imports {
        println!("{}", filename);
    } else if args.set_import {
        if args.free_args.len() == 3 {
            println!(
                "set-import: {}, {}, {}",
                args.free_args[0], args.free_args[1], args.free_args[2]
            );
        } else {
            eprintln!("Error: --set-import requires exactly 3 arguments.");
        }
    } else {
        eprintln!("Error: one of --version, --list-imports or --set-import must be provided.");
        println!("{}", Args::usage());
        process::exit(1);
    }
}

why does the text LIST-IMPORTS in call caps appear?!

.\fixPath.exe -h
Usage: C:\Users\joschie\Desktop\Projects\fixPath\target\debug\fixPath.exe [OPTIONS]

Positional arguments:
  free_args

Optional arguments:
  -v, --version     Prints the version
  -l, --list-imports LIST-IMPORTS
                    Prints <file>'s DLL bindings
  -s, --set-import  Updates <file>'s DLL bindings <from> so it points to <to>
  -h, --help        Print this help message and exit

https://replit.com/@qknight/gumdrop-example#src/main.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant