├── docs ├── api │ ├── .lock │ ├── crates.js │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── FiraSans-Medium.woff2 │ ├── noscript.css │ ├── FiraSans-Regular.woff2 │ ├── NanumBarunGothic.ttf.woff2 │ ├── SourceCodePro-It.ttf.woff2 │ ├── SourceSerif4-It.ttf.woff2 │ ├── SourceSerif4-Bold.ttf.woff2 │ ├── SourceCodePro-Regular.ttf.woff2 │ ├── SourceSerif4-Regular.ttf.woff2 │ ├── SourceCodePro-Semibold.ttf.woff2 │ ├── source-files.js │ ├── toggle-minus.svg │ ├── toggle-plus.svg │ ├── down-arrow.svg │ ├── implementors │ │ ├── std │ │ │ └── error │ │ │ │ └── trait.Error.js │ │ └── core │ │ │ ├── fmt │ │ │ ├── trait.Display.js │ │ │ └── trait.Debug.js │ │ │ ├── marker │ │ │ ├── trait.Copy.js │ │ │ ├── trait.Freeze.js │ │ │ ├── trait.Send.js │ │ │ ├── trait.Sync.js │ │ │ ├── trait.Unpin.js │ │ │ └── trait.StructuralPartialEq.js │ │ │ ├── default │ │ │ └── trait.Default.js │ │ │ ├── clone │ │ │ └── trait.Clone.js │ │ │ ├── panic │ │ │ └── unwind_safe │ │ │ │ ├── trait.UnwindSafe.js │ │ │ │ └── trait.RefUnwindSafe.js │ │ │ └── cmp │ │ │ └── trait.PartialEq.js │ ├── clipboard.svg │ ├── cliparser │ │ ├── types │ │ │ ├── sidebar-items.js │ │ │ └── index.html │ │ ├── sidebar-items.js │ │ ├── all.html │ │ ├── fn.help.html │ │ ├── fn.version.html │ │ ├── fn.parse_process.html │ │ ├── fn.parse_process_any.html │ │ └── fn.parse_any.html │ ├── LICENSE-MIT.txt │ ├── settings.css │ ├── normalize.css │ ├── COPYRIGHT.txt │ ├── storage.js │ ├── rust-logo.svg │ ├── wheel.svg │ ├── settings.html │ ├── favicon.svg │ ├── source-script.js │ ├── FiraSans-LICENSE.txt │ ├── SourceSerif4-LICENSE.md │ ├── SourceCodePro-LICENSE.txt │ ├── NanumBarunGothic-LICENSE.txt │ ├── settings.js │ ├── light.css │ └── dark.css └── index.html ├── .gitattributes ├── .rusty-hook.toml ├── .gitignore ├── .github ├── dependabot.yml ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── workflows │ └── ci.yml └── CONTRIBUTING.md ├── .editorconfig ├── CHANGELOG.md ├── Makefile.toml ├── Cargo.toml ├── tests ├── parse_any_test.rs └── parse_test.rs ├── benches └── bench_parse.rs ├── src ├── types_test.rs ├── types.rs ├── help.rs └── lib_test.rs ├── examples └── example.rs └── README.md /docs/api/.lock: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/crates.js: -------------------------------------------------------------------------------- 1 | window.ALL_CRATES = ["cliparser"]; -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | *.ico binary 3 | *.woff binary 4 | -------------------------------------------------------------------------------- /.rusty-hook.toml: -------------------------------------------------------------------------------- 1 | [hooks] 2 | pre-push = "cargo make ci-flow" 3 | -------------------------------------------------------------------------------- /docs/api/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/cliparser/HEAD/docs/api/favicon-16x16.png -------------------------------------------------------------------------------- /docs/api/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/cliparser/HEAD/docs/api/favicon-32x32.png -------------------------------------------------------------------------------- /docs/api/FiraSans-Medium.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/cliparser/HEAD/docs/api/FiraSans-Medium.woff2 -------------------------------------------------------------------------------- /docs/api/noscript.css: -------------------------------------------------------------------------------- 1 | #main-content .attributes{margin-left:0 !important;}#copy-path{display:none;}.sub{display:none;} -------------------------------------------------------------------------------- /docs/api/FiraSans-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/cliparser/HEAD/docs/api/FiraSans-Regular.woff2 -------------------------------------------------------------------------------- /docs/api/NanumBarunGothic.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/cliparser/HEAD/docs/api/NanumBarunGothic.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/SourceCodePro-It.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/cliparser/HEAD/docs/api/SourceCodePro-It.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/SourceSerif4-It.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/cliparser/HEAD/docs/api/SourceSerif4-It.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/SourceSerif4-Bold.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/cliparser/HEAD/docs/api/SourceSerif4-Bold.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/SourceCodePro-Regular.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/cliparser/HEAD/docs/api/SourceCodePro-Regular.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/SourceSerif4-Regular.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/cliparser/HEAD/docs/api/SourceSerif4-Regular.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/SourceCodePro-Semibold.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/cliparser/HEAD/docs/api/SourceCodePro-Semibold.ttf.woff2 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .c9 3 | /target 4 | temp/ 5 | **/*.rs.bk 6 | Cargo.lock 7 | **/*.log 8 | dump.rdb 9 | /rs*.sh 10 | /docs/_site 11 | /core 12 | -------------------------------------------------------------------------------- /docs/api/source-files.js: -------------------------------------------------------------------------------- 1 | var sourcesIndex = {}; 2 | sourcesIndex["cliparser"] = {"name":"","files":["help.rs","lib.rs","parser.rs","types.rs"]}; 3 | createSourceSidebar(); 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: cargo 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: '03:00' 8 | open-pull-requests-limit: 99 9 | -------------------------------------------------------------------------------- /docs/api/toggle-minus.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toggle-plus.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | indent_style = space 10 | indent_size = 4 11 | 12 | [*.json] 13 | indent_size = 2 14 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## CHANGELOG 2 | 3 | ### v0.1.2 (2022-07-21) 4 | 5 | * Support windows paths for command scanning 6 | 7 | ### v0.1.1 (2022-07-21) 8 | 9 | * Ignore extensions while scanning for commands 10 | 11 | ### v0.1.0 (2022-07-21) 12 | 13 | * Initial release 14 | -------------------------------------------------------------------------------- /Makefile.toml: -------------------------------------------------------------------------------- 1 | 2 | [config] 3 | additional_profiles = [ 4 | "all-default-tasks", 5 | "multi-phase-tests", 6 | "docs-all-modification-tasks", 7 | "ci-coverage-tasks", 8 | "ci-all-build-tasks", 9 | "ci-static-code-analysis-tasks", 10 | "publish-pre-cleanup", 11 | ] 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: sagiegurari 7 | 8 | --- 9 | 10 | ### Feature Description 11 | 12 | 13 | ### Describe The Solution You'd Like 14 | 15 | 16 | ### Code Sample 17 | 18 | ```rust 19 | /// paste code here 20 | ``` 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: sagiegurari 7 | 8 | --- 9 | 10 | ### Describe The Bug 11 | 12 | 13 | ### To Reproduce 14 | 15 | 16 | ### Error Stack 17 | 18 | ```console 19 | The error stack trace 20 | ``` 21 | 22 | ### Code Sample 23 | 24 | ```rust 25 | /// paste code here 26 | ``` 27 | -------------------------------------------------------------------------------- /docs/api/down-arrow.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/implementors/std/error/trait.Error.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["cliparser"] = [{"text":"impl Error for ParserError","synthetic":false,"types":["cliparser::types::ParserError"]}]; 3 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/api/clipboard.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/api/implementors/core/fmt/trait.Display.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["cliparser"] = [{"text":"impl Display for ParserError","synthetic":false,"types":["cliparser::types::ParserError"]}]; 3 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/api/cliparser/types/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"enum":[["ArgumentHelp","The argument help text"],["ArgumentOccurrence","The argument occurrence type (see values for more info)"],["ArgumentValueType","The argument value type (see values for more info)"],["Command","The command (not params) string/s"],["ParserError","Holds the error information"]],"struct":[["Argument","Holds the command line argument spec"],["CliParsed","Holds the command line parse result"],["CliSpec","Holds the command line spec (command/parameters/…)"],["CliSpecMetaInfo","Holds the command line spec meta information used to generate version and help messages"],["PositionalArgument","Holds the positional argument spec"]]}); -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: [push, pull_request] 3 | env: 4 | CLICOLOR_FORCE: 1 5 | jobs: 6 | ci: 7 | name: CI 8 | runs-on: ${{ matrix.os }} 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | rust: [stable, beta, nightly] 13 | os: [ubuntu-latest, windows-latest, macOS-latest] 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v4 17 | - name: Install rust 18 | uses: dtolnay/rust-toolchain@master 19 | with: 20 | toolchain: ${{ matrix.rust }} 21 | - name: Install cargo-make 22 | run: cargo install --debug cargo-make 23 | - name: Run CI 24 | env: 25 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 26 | run: cargo make ci-flow 27 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cliparser" 3 | version = "0.1.2" 4 | authors = ["Sagie Gur-Aripub fn parse_process(spec: &CliSpec) -> Result<CliParsed, ParserError>Parsers the given command line based on the given spec and returns the result.
10 | In case of error (such as invalid input), an error will be returned.
11 | In case the command line does not match the spec, Ok(None) will be returned.
Parsers the current process command line based on the given specs and returns the result.
10 | In case of invalid input or none of the provided specs do not match the command line, an error will be returned.
pub fn parse_any(
command_line: &Vec<&str>,
specs: Vec<&CliSpec>
) -> Result<(usize, CliParsed), ParserError>Parsers the given command line based on the given specs and returns the result.
10 | In case of invalid input or none of the provided specs do not match the command line, an error will be returned.
Defines the various types.
11 |Holds the command line argument spec
13 |Holds the command line parse result
14 |Holds the command line spec (command/parameters/…)
15 |Holds the command line spec meta information used to generate version and help messages
16 |Holds the positional argument spec
17 |The argument help text
19 |The argument occurrence type (see values for more info)
20 |The argument value type (see values for more info)
21 |The command (not params) string/s
22 |Holds the error information
23 |