@@ -3,64 +3,61 @@ use clap::{Parser, ValueEnum};
3
3
#[ derive( Parser ) ]
4
4
#[ command( author, about, next_line_help = true ) ]
5
5
pub struct Args {
6
- /// The string that joines the random words, if there are more than 1
7
- #[ arg( short, long, default_value_t = String :: from( " " ) ) ]
8
- joiner : String ,
6
+ /// The string that joines the random words, if there are more than 1
7
+ #[ arg( short, long, default_value_t = String :: from( " " ) ) ]
8
+ joiner : String ,
9
9
10
- /// Sets the case of every word
11
- #[ arg( short, long, value_enum, default_value_t = Case :: Lower ) ]
12
- case : Case ,
10
+ /// Sets the case of every word
11
+ #[ arg( short, long, value_enum, default_value_t = Case :: Lower ) ]
12
+ case : Case ,
13
13
14
- /// Disable interpreting \n as a newline and \t as a tab
15
- #[ arg( short, long) ]
16
- raw : bool ,
14
+ /// Disable interpreting \n as a newline and \t as a tab
15
+ #[ arg( short, long) ]
16
+ raw : bool ,
17
17
18
- /// Amount of random words to print
19
- #[ arg( default_value_t = 1 ) ]
20
- pub amount : usize ,
18
+ /// Amount of random words to print
19
+ #[ arg( default_value_t = 1 ) ]
20
+ pub amount : usize ,
21
21
}
22
22
23
23
impl Args {
24
- pub fn get_joiner ( & self ) -> String {
25
- if self . raw {
26
- self . joiner . clone ( )
27
- } else {
28
- self . joiner
29
- . clone ( )
30
- . replace ( "\\ n" , "\n " )
31
- . replace ( "\\ t" , "\t " )
32
- }
33
- }
34
-
35
- pub fn alter_case ( & self , mut words : Vec < String > ) -> Vec < String > {
36
- self . case . alter_case ( & mut words) ;
37
- words. to_vec ( )
38
- }
24
+ pub fn get_joiner ( & self ) -> String {
25
+ if self . raw {
26
+ self . joiner . clone ( )
27
+ } else {
28
+ self . joiner . clone ( ) . replace ( "\\ n" , "\n " ) . replace ( "\\ t" , "\t " )
29
+ }
30
+ }
31
+
32
+ pub fn alter_case ( & self , mut words : Vec < String > ) -> Vec < String > {
33
+ self . case . alter_case ( & mut words) ;
34
+ words. to_vec ( )
35
+ }
39
36
}
40
37
41
38
#[ derive( ValueEnum , Clone , Copy ) ]
42
39
pub enum Case {
43
- Caps ,
44
- Title ,
45
- Lower ,
40
+ Caps ,
41
+ Title ,
42
+ Lower ,
46
43
}
47
44
48
45
impl Case {
49
- fn alter_case ( self , words : & mut [ String ] ) {
50
- match self {
51
- Self :: Caps => {
52
- for x in words. iter_mut ( ) {
53
- x. make_ascii_uppercase ( ) ;
54
- }
55
- }
56
-
57
- Self :: Title => {
58
- for x in words. iter_mut ( ) {
59
- x[ 0 ..1 ] . make_ascii_uppercase ( ) ;
60
- }
61
- }
62
-
63
- Self :: Lower => { }
64
- }
65
- }
46
+ fn alter_case ( self , words : & mut [ String ] ) {
47
+ match self {
48
+ Self :: Caps => {
49
+ for x in words. iter_mut ( ) {
50
+ x. make_ascii_uppercase ( ) ;
51
+ }
52
+ }
53
+
54
+ Self :: Title => {
55
+ for x in words. iter_mut ( ) {
56
+ x[ 0 ..1 ] . make_ascii_uppercase ( ) ;
57
+ }
58
+ }
59
+
60
+ Self :: Lower => { }
61
+ }
62
+ }
66
63
}
0 commit comments