Skip to content

Commit

Permalink
Improve --help-* output
Browse files Browse the repository at this point in the history
  • Loading branch information
jpikl committed Feb 14, 2021
1 parent 8366f92 commit 26ec339
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/bin/rew/pattern/help.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
use indoc::indoc;

pub const PATTERN: &str = indoc! {r#"
# Syntax
# SYNTAX
`abc` Constant
`{}` Empty expression
`{x}` Expression with a filter
`{x|y|z}` Expression with multiple filters
`a{}b{x|y}c` Example of a more complex pattern
# Rules
# RULES
Constants are directly copied to output.
Expression is replaced by input value
Filters are consecutively applied on input value.
"#};

pub const FILTERS: &str = indoc! {r#"
# Paths
# PATH
`d` Parent directory `D` Remove last name
`f` File name `F` Last name
Expand All @@ -31,33 +31,33 @@ pub const FILTERS: &str = indoc! {r#"
`z` Ensure trailing separator `Z` Remove trailing separator
# Substrings
# SUBSTRINGS
`nA-B` From `A` to `B` (`n` = normal indexing)
`nA+L` From `A` with length `L` (`N` = backward indexing)
`nA-` From `A` to end (`A`, `B` = inclusive 1-based indices)
`nA` Character at `A`
# Replacement
# REPLACEMENT
`r:X:Y` Replace `X` with `Y` (`r` = first occurence)
`r:X` Remove `X` (`R` = all occurences)
`?D` Replace empty with `D` (`:` = any separator)
# Regular expressions
# REGULAR EXPRESSIONS
`=E` Match of regex `E` (`:` = any separator)
`s:X:Y` Replace match of `X` with `Y` (`s` = first occurence)
`s:X` Remove match of `X` (`S` = all occurences)
`@:X1:Y1:...:Xn:Yn:D` Output `Yi` for first match of `Xi`, `D` for no match
`@:X1:Y1:...:Xn:Yn:D` Output `Yi` for first match of `Xi`, `D` for no match
`0`, `1`, `2`, ... Capture group of a global regex
`$0`, `$1`, `$2`, ... Capture group inside `s/S/@`
`0`, `1`, `2`, ... Capture group of a global regex
`$0`, `$1`, `$2`, ... Capture group inside `s/S/@`
# Formatting
# FORMATTING
`t` Trim
`v` To lowercase `^` To uppercase
Expand All @@ -67,9 +67,9 @@ pub const FILTERS: &str = indoc! {r#"
`<N:M` Left pad `N` times with `M` (`:` = any separator)
# Generators
# GENERATORS
`*N:V` Repeat `N` times `V` (`:` = any separator)
`*N:V` Repeat `N` times `V` (`:` = any separator)
`c` Local counter `C` Global counter
`u` Random 64-bit number `U` Random UUID
Expand Down

0 comments on commit 26ec339

Please sign in to comment.