{"id":17255265,"url":"https://github.com/anthonymichaeltdm/clia","last_synced_at":"2025-04-14T05:41:38.046Z","repository":{"id":62444411,"uuid":"476107334","full_name":"AnthonyMichaelTDM/CLIA","owner":"AnthonyMichaelTDM","description":"Rust command-line argument parser with no extra dependencies.","archived":false,"fork":false,"pushed_at":"2022-05-02T01:14:38.000Z","size":81,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T04:58:14.572Z","etag":null,"topics":["command-line","parser","rust","rust-crate"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AnthonyMichaelTDM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-31T01:25:07.000Z","updated_at":"2024-09-14T17:07:26.000Z","dependencies_parsed_at":"2022-11-01T23:33:43.718Z","dependency_job_id":null,"html_url":"https://github.com/AnthonyMichaelTDM/CLIA","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnthonyMichaelTDM%2FCLIA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnthonyMichaelTDM%2FCLIA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnthonyMichaelTDM%2FCLIA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnthonyMichaelTDM%2FCLIA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AnthonyMichaelTDM","download_url":"https://codeload.github.com/AnthonyMichaelTDM/CLIA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830419,"owners_count":21168272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line","parser","rust","rust-crate"],"created_at":"2024-10-15T07:11:07.040Z","updated_at":"2025-04-14T05:41:38.028Z","avatar_url":"https://github.com/AnthonyMichaelTDM.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CLIA\npronouced KLEE-uh\n\nRust command-line argument parser with no extra dependencies.\n\nthis is a crate with tools for parsing command-line arguments.\n## Features\n- Generating help messages based on available options,\n- Support for all the types of arguments specified later\n\n## Usage\n### supported types of arguments\nAs far as this crate is concerned, there are 4 types of arguments, in 2 main groups\n\nOptions:\n- flags (ei. `-r`)\n- flags w/ lists (ei `-f [comma separated list]` )\n- flags w/ data (ei `--format \u003cNUMERIC\u003e`)\n\nand Parameters:\n- (ei a file path, a string, etc.)\n \nThis crate makes the following assumptions about your command line program:\n- all options / flags start with a `-`\n- lists entered in the command line are comma separated\n- options and their associated bits of data, are typed before any parameter arguments (programs usage follows this pattern: `foo.exe [OPTIONS]... [PARAMETERS]`)\n- any and all \"Parameters\" are required, and must be included in the arguments for your program to work properly (optional arguments should be tied to flags anyway)\n\n### installing\n[see on crates.io](https://crates.io/crates/clia)\n\nadd `clia=0.1.3` to the [dependencies] of your projects cargo.toml like so:\n\ncargo.toml:\n```rust\n[dependencies]\nclia=\"0.1.3\"\n```\n\n## Example\nHere is an example showcasing all the basic features of CLIO.\n```rust\nuse std::env;\n\nuse clia::{option_args::{ClOption,ClOptionInfo},parameter_args::ClParameter,Parser};\n\n/// this is just an example of using this crate\nfn main() {\n    /* step 1: define options and parameters */\n    let mut valid_options: Vec\u003cClOption\u003e = Vec::new();\n    let mut expected_parameters: Vec\u003cClParameter\u003e = Vec::new();\n\n    // define options\n    //  this is an example of making an option with a list\n    valid_options.push( ClOption::new_flag_list( \n        \u0026ClOptionInfo::new(\n            \"-f\", \n            \"--filter\", \n            \"Comma separated list of extensions, will only count lines of files with these extensions\"\n        ).unwrap(),\n        \"EXTENSIONS\"\n    ));\n    //  this is an example of making an option with some data\n    valid_options.push( ClOption::new_flag_data( \n        \u0026ClOptionInfo::new(\n            \"-F\", \n            \"--format\", \n            \"Format the output in a list, valid formats are: DEFAULT, BULLET, MARKDOWN, and NUMERIC\"\n        ).unwrap(),\n        \"FORMAT\"\n    ));\n    //  this is an example of making a simple option\n    valid_options.push( ClOption::new_flag( \n        \u0026ClOptionInfo::new(\n            \"-r\", \n            \"--recursive\", \n            \"Search through subdirectories\"\n        ).unwrap()\n    ));\n    //  this is an example of making a simple option\n    valid_options.push( ClOption::new_flag( \n        \u0026ClOptionInfo::new(\n            \"-h\", \n            \"--help\", \n            \"Prints help information\"\n        ).unwrap()\n    ));\n\n    // define parameters\n    expected_parameters.push( ClParameter::new(\n        \"PATH\",\n        \"Path to file/folder to search\"\n    ));\n    expected_parameters.push( ClParameter::new(\n        \"QUERY\",\n        \"String to search for, all the stuff after the path wrap in \\\"'s if it contains spaces\"\n    ));\n    \n    \n    \n    /* step 2: collect CLI Arguments and call the parser */\n    let args: Vec\u003cString\u003e = env::args().collect(); //read the argument values from env, and collect them into a string vector\n    \n    //call parser\n    let arg_parser;\n    match Parser::new(\u0026args, \u0026valid_options, \u0026expected_parameters) {\n        Ok(arg_par) =\u003e arg_parser = arg_par,\n        Err(e) =\u003e {println!(\"{}\", Parser::help(\"foo.exe\", \"by Anthony Rubick\", \"Just here as an example of things you can do\", \u0026valid_options, \u0026expected_parameters)); panic!(\"{}\", e);}, //print any errors that occur\n    }\n    \n    \n    \n    /* step 3: access the \"found\" fields of the parser */\n    //store data from the parser\n    let found_options = arg_parser.get_option_arguments_found();\n    let found_parameters = arg_parser.get_parameter_arguments_found();\n    \n    \n    \n    /* process the arguments */\n    //user passed the -h flag\n    if found_options.iter().any(|opt| opt.get_info().get_short_flag().eq(\"-h\")) {\n        println!(\"{}\", Parser::help(\"foo.exe\", \"by Anthony Rubick\", \"Just here as an example of things you can do\", \u0026valid_options, \u0026expected_parameters));\n    }\n    \n    // ...\n}\n```\noutput of -h\n```\nfoo.exe\nby Anthony Rubick\n\nJust here as an example of things you can do\n\nUSAGE: foo.exe [OPTIONS]... [PATH] [QUERY]\n\nOPTIONS:\n    -f, --filter \u003cEXTENSIONS\u003e...      Comma separated list of extensions, will only count lines of files with these extensions\n    -F, --format \u003cFORMAT\u003e             Format the output in a list, valid formats are: DEFAULT, BULLET, MARKDOWN, and NUMERIC\n    -r, --recursive                   Search through subdirectories\n    -h, --help                        Prints help information\n\nPARAMETER ARGUMENTS:\n    PATH:\n        Path to file/folder to search\n    QUERY:\n        String to search for, all the stuff after the path wrap in \"'s if it contains spaces\n```\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonymichaeltdm%2Fclia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanthonymichaeltdm%2Fclia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonymichaeltdm%2Fclia/lists"}