1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! An example of using patharg with clap
//!
//! Run with `cargo run --example flipcase --features examples`
//!
//! Say you're using clap to write a command named "flipcase" that flips the
//! cases of all the letters in a file, changing uppercase to lowercase and
//! lowercase to uppercase, and you want this command to take a path to a file
//! to read input from and another path for the file to write the output to.
//! By using `patharg::InputArg` and `patharg::OutputArg` as the types of the
//! arguments in your `clap::Parser`, flipcase will treat a '-' argument as
//! referring to stdin/stdout, and you'll be able to use the types' methods to
//! read or write from any filepath or standard stream given on the command
//! line.
//!
//! flipcase can then be invoked in the following ways:
//!
//! - `flipcase` — Read input from stdin, write output to stdout
//! - `flipcase file.txt` — Read input from `file.txt`, write output to stdout
//! - `flipcase -` — Read input from stdin, write output to stdout
//! - `flipcase -o out.txt` — Read input from stdin, write output to `out.txt`
//! - `flipcase -o -` — Read input from stdin, write output to stdout
//! - `flipcase -o out.txt file.txt` — Read input from `file.txt`, write output
//! to `out.txt`
//! - `flipcase -o out.txt -` — Read input from stdin, write output to
//! `out.txt`
//! - `flipcase -o - file.txt` — Read input from `file.txt`, write output to
//! stdout
//! - `flipcase -o - -` — Read input from stdin, write output to stdout
use Parser;
use ;
use Write;
/// Flip the cases of all the letters in a file.