Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: BonnyAD9/pareg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.0
Choose a base ref
...
head repository: BonnyAD9/pareg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Apr 18, 2024

  1. Fmt

    BonnyAD9 committed Apr 18, 2024
    Copy the full SHA
    2dc85d0 View commit details
  2. Fix visibility + add docs

    BonnyAD9 committed Apr 18, 2024
    Copy the full SHA
    0c9dfdc View commit details

Commits on Apr 19, 2024

  1. Copy the full SHA
    d5501f6 View commit details
  2. Update changelog

    BonnyAD9 committed Apr 19, 2024
    Copy the full SHA
    099d6a4 View commit details
  3. Improve the ArgIterator

    BonnyAD9 committed Apr 19, 2024
    Copy the full SHA
    9392b5f View commit details
  4. Copy the full SHA
    620ac95 View commit details
  5. Bump versions

    BonnyAD9 committed Apr 19, 2024
    Copy the full SHA
    00f1ceb View commit details
  6. Copy the full SHA
    65d72a5 View commit details
  7. Update changelog

    BonnyAD9 committed Apr 19, 2024
    Copy the full SHA
    b37ab6c View commit details
  8. Bump versions

    BonnyAD9 committed Apr 19, 2024
    Copy the full SHA
    9145502 View commit details

Commits on Jun 24, 2024

  1. Copy the full SHA
    a8db62d View commit details
  2. Remove lifetime from result

    BonnyAD9 committed Jun 24, 2024
    Copy the full SHA
    b763b52 View commit details
  3. Copy the full SHA
    134c265 View commit details
  4. Copy the full SHA
    636b88c View commit details
  5. Update readme

    BonnyAD9 committed Jun 24, 2024
    Copy the full SHA
    a676707 View commit details

Commits on Jun 25, 2024

  1. Update readme

    BonnyAD9 committed Jun 25, 2024
    Copy the full SHA
    a7e5f1b View commit details
  2. Bump version

    BonnyAD9 committed Jun 25, 2024
    Copy the full SHA
    8495896 View commit details

Commits on Sep 14, 2024

  1. Copy the full SHA
    755057e View commit details

Commits on Sep 25, 2024

  1. Fix dependencies

    BonnyAD9 committed Sep 25, 2024
    Copy the full SHA
    50edb54 View commit details
  2. Store ErrCtx in box

    BonnyAD9 committed Sep 25, 2024
    Copy the full SHA
    82ddd7c View commit details

Commits on Oct 25, 2024

  1. Refactor errors.

    BonnyAD9 committed Oct 25, 2024
    Copy the full SHA
    4e5b216 View commit details
  2. Add colors to errors.

    BonnyAD9 committed Oct 25, 2024
    Copy the full SHA
    1387af8 View commit details
  3. Bump version

    BonnyAD9 committed Oct 25, 2024
    Copy the full SHA
    3d5a23f View commit details
  4. Add argument getters

    BonnyAD9 committed Oct 25, 2024
    Copy the full SHA
    f7d3a74 View commit details

Commits on Nov 3, 2024

  1. Add cur_val_or_next

    BonnyAD9 committed Nov 3, 2024
    Copy the full SHA
    f0cefc9 View commit details
  2. Add invalid value errors.

    BonnyAD9 committed Nov 3, 2024
    Copy the full SHA
    cfb6920 View commit details
  3. Fix changelog and doc.

    BonnyAD9 committed Nov 3, 2024
    Copy the full SHA
    f41fc3a View commit details

Commits on Nov 9, 2024

  1. Avoid lifetime conflicts.

    BonnyAD9 committed Nov 9, 2024
    Copy the full SHA
    e6c2b2d View commit details
  2. Fix

    BonnyAD9 committed Nov 9, 2024
    Copy the full SHA
    ce5cafe View commit details
  3. Update changelog.

    BonnyAD9 committed Nov 9, 2024
    Copy the full SHA
    00c2408 View commit details

Commits on Dec 14, 2024

  1. Add missing documentation

    BonnyAD9 committed Dec 14, 2024
    Copy the full SHA
    6f8cbd6 View commit details

Commits on Dec 16, 2024

  1. Add convinience methods.

    BonnyAD9 committed Dec 16, 2024
    Copy the full SHA
    9310a55 View commit details

Commits on Dec 17, 2024

  1. Copy the full SHA
    331c3e8 View commit details

Commits on Dec 18, 2024

  1. Copy the full SHA
    2105901 View commit details

Commits on Dec 21, 2024

  1. Add skipping

    BonnyAD9 committed Dec 21, 2024
    Copy the full SHA
    160bc79 View commit details

Commits on Dec 22, 2024

  1. Add todo

    BonnyAD9 committed Dec 22, 2024
    Copy the full SHA
    5875c52 View commit details

Commits on Dec 23, 2024

  1. Jump and reset

    BonnyAD9 committed Dec 23, 2024
    Copy the full SHA
    91f89e3 View commit details

Commits on Jan 3, 2025

  1. Start implementing parsef

    BonnyAD9 committed Jan 3, 2025
    Copy the full SHA
    e32b482 View commit details
  2. Don't include unfinished

    BonnyAD9 committed Jan 3, 2025
    Copy the full SHA
    0f54de1 View commit details
  3. Copy the full SHA
    5de7bb2 View commit details
  4. Bump version

    BonnyAD9 committed Jan 3, 2025
    Copy the full SHA
    21e04da View commit details
  5. Fix changelog

    BonnyAD9 committed Jan 3, 2025
    Copy the full SHA
    348e400 View commit details
  6. Add reader and from_read

    BonnyAD9 committed Jan 3, 2025
    Copy the full SHA
    284f5fd View commit details
  7. Fix FromRead

    BonnyAD9 committed Jan 3, 2025
    Copy the full SHA
    83dd15b View commit details
  8. Copy the full SHA
    d8dd174 View commit details
  9. Implement parsef function.

    BonnyAD9 committed Jan 3, 2025
    Copy the full SHA
    38da43d View commit details
  10. Add parsef macro

    BonnyAD9 committed Jan 3, 2025
    Copy the full SHA
    0ffadbb View commit details

Commits on Jan 30, 2025

  1. Add try_set parsers

    BonnyAD9 committed Jan 30, 2025
    Copy the full SHA
    c28f8e2 View commit details

Commits on Feb 8, 2025

  1. Add ParegRef

    BonnyAD9 committed Feb 8, 2025
    Copy the full SHA
    68d0646 View commit details
  2. Doc

    BonnyAD9 committed Feb 8, 2025
    Copy the full SHA
    63dbfcf View commit details
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/.vscode
96 changes: 96 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# CHANGELOG

## future
### Fixes
- Fix typo in error message.

## v0.9.0
### New features
- Add `FromRead` implementations for `f32`, `f64`, `bool`, `char`, `String`,
`PathBuf`, `OsString`, `Ipv4Addr` and `SocketAddrV4`.
- Add new methods to `Reader`: `skip_while`, `is_next_some`, `is_next`,
`chars`, `parse` and `next`.

### Changes
- `Reader` no longer implements the iterator trait. Use `.chars()` to get
iterator over chars.

## v0.8.0
### New features
- Add parsers `try_set_arg_with` and `try_set_arg`.
- Add pareg methods `try_set_cur_with`, `try_set_next_with`, `try_set_cur` and
`try_set_next`.
- Add parsef functionality (function and macro).
- Add `Reader` for parsing.
- Add `ParegRef`. It allows parsing to continue even if there are references to
the original arguments.
- Add checkers: `check::CheckRef`, `check::InRangeI` and `check::InRange`.
- Add new parsers `split_arg` and `arg_list` and their respective methods on
`ParegRef` and `Pareg`.
- Add new macros `impl_from_str_with_read!` and `impl_from_arg_str_with_read!`.

### Changes
- Rename `Pareg::map_err` to `Pareg::map_res`, add `Pareg::map_err`.

## v0.7.0
+ Add `Pareg::cur_idx` and `Pareg::next_idx`
+ Add `Pareg::peek` and `Pareg::get`
+ Add `Pareg::skip` and `Pareg::skip_all`.
+ Add `Pareg::jump` and `Pareg::reset`.
+ Add `Error::TooManyArguments`.
+ Add `color_mode` and `no_color` to `ArgError` and `ArgErrCtx`.
- Fix `Pareg::remaining` and `Pareg::cur_remaining`.

## v0.6.1
- Fix panic in `Pareg::remaining`.

## v0.6.0
- Add `all_arg`, `remaining` and `cur_remaining` to `Pareg`.
- Add `cur_val_or_next` to `Pareg`.
- Add new error for checking value validity `ArgError::InvalidValue`.
- Add `err_invalid`, `err_invalid_value` and `err_invalid_span` to `Pareg`.
- Make `ArgErrCtx::from_msg` take `impl Into<Cow>` instead of `String`.
- Add `ArgErrCtx::spanned` and `ArgError::spanned`.
- Add `ArgErrCtx::from_inner`.
- Add `part_of`, `inline_msg` and `main_msg` to `ArgErrCtx` and `ArgError`.
- Add `parse_msg` and `err` to `ArgError`
- Require `FromArg` to return `Result<ArgError, T>`
- Remove unncesary mut requirements on `Pareg`.

## v0.5.2
- Make errors store box of ErrCtx to reduce the size of the results.
- Add colors to errors (modify defaults with features).

## v0.5.1
- Fix dependencies

## v0.5.0
- Very user friendly error messages.
- Remove `ArgIterator` in favor of `Pareg`. They both have very similar
functionality, but work in a sligtly different way that allows the better
error messages.

## v0.4.0
- Add new parsers: `key_arg`, `val_arg`, `mval_arg` and their implementations
on `ArgIterator`
- Remove lifetime from errors
- Move proc macro to the same namespace as its trait.
- Add macros `starts_any` and `has_any_key`

## v0.3.0
- Add `arg` attribute to `FromArg` derive macro.

## v0.2.0
- Make `ArgIterator` struct instead of trait
- Remember the last returned value on `ArgIterator`
- More parsing option s on `ArgIterator`

## v0.1.1
- Fix visibility of certain items
- Additional documentation

## v0.1.0
- ArgIterator iterator for command line arguments, supports parsing
- Functions for parsing arguments:
- key_mval_arg, key_val_arg, bool_arg, opt_bool_arg
- FromArg derive proc macro for enums
128 changes: 114 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pareg"
version = "0.1.0"
version = "0.9.0"
edition = "2021"
license-file = "LICENSE"
description = "Rust library with useful tools for command line argument parsing"
@@ -17,5 +17,5 @@ members = [
]

[dependencies]
pareg_core = { version = "0.1.0", path = "pareg_core" }
pareg_proc = { version = "0.1.0", path = "pareg_proc" }
pareg_core = { version = "0.9.0", path = "pareg_core" }
pareg_proc = { version = "0.9.0", path = "pareg_proc" }
34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,11 +4,35 @@

Helpful utilities for parsing command line arguments.

Currently this crate doesn't contain any magic derive macro that would generate
code that parses your arguments. There are many ways that arguments may be used
and so there are only helper functions, traits and structures that help with
the parsing in a more manual way. (But there may be such derive macro in
the future.)
The aim of this crate is not to automate parsing of command line arguments
because there are many ways to construct a CLI for your application and
universal parser is not would be as hard to use as just writing it yourself.
Instead this crate provides useful types and parsing funcitonality to make the
process of writing your own code to parse command line arguments as simple as
possible: It provides special struct for parsing the arguments in various ways
and plenty of useful parsing functions and macros. Everything is made to
minimize the repetetive part of the code for parsing the arguments and
providing very user friendly error messages out of the box. If you wan't to see
examples see [docs][docs].

### Main constructs:
- `Pareg`: istruct that will help with parsing of arguments.
- `FromArg`: trait simmilar to `FromStr`. It is used by all the parsing
functionality in this crate. There is also simple derive macro for enums.
- It is implemented for all types in standard library that implement
`FromStr` and there is simple trait to just mark `FromStr` implementation
as also `FromArg`: `FromArgStr`.
- macros `starts_any` and `has_any_key`: useful for checking argument types.

### Example error message
```txt
argument error: Unknown option `no`.
--> arg1:8..10
|
$ my-program --color=no
| ^^ Unknown option.
hint: Valid options are: `auto`, `always`, `never`.
```

## How to use it
Documentation and examples are available at the [docs][docs].
3 changes: 3 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Parse macro. (reverse of format).
- More error types.
- Custom parse methods for rust types with better errors.
Loading