@@ -8,10 +8,10 @@ use std::str::FromStr;
8
8
#[ derive( Parser , Debug ) ]
9
9
pub ( crate ) struct Week {
10
10
/// Week number (defaults to current week if omitted)
11
- #[ arg( long = "week" , short) ]
11
+ #[ arg( long = "week" , short = 'w' ) ]
12
12
pub ( crate ) number : Option < u8 > ,
13
13
14
- /// N:th previous week counted from current week (defaults to 1 if N isn't specified )
14
+ /// N:th previous week counted from current week (defaults to 1 if N is omitted )
15
15
#[ arg(
16
16
long = "previous-week" ,
17
17
short,
@@ -27,6 +27,34 @@ pub(crate) struct Week {
27
27
pub ( crate ) year : Option < i32 > ,
28
28
}
29
29
30
+ #[ derive( Parser , Debug ) ]
31
+ pub ( crate ) struct Task {
32
+ /// Name of the job
33
+ #[ arg( long, short) ]
34
+ pub ( crate ) job : String ,
35
+
36
+ /// Name of the task
37
+ #[ arg( long = "task" , short = 't' ) ]
38
+ pub ( crate ) name : String ,
39
+ }
40
+
41
+ #[ derive( Parser , Debug ) ]
42
+ pub ( crate ) struct Day {
43
+ /// Day(s) of the week, for example "tuesday"
44
+ ///
45
+ /// Defaults to today if omitted
46
+ ///
47
+ /// You can also specify multiple days, and/or a range of days, for example
48
+ /// "monday-tuesday, friday"
49
+ ///
50
+ /// Also accepts short day names like "mon", "tue", etc.
51
+ #[ arg( long, short, value_parser = parse_days_of_week) ]
52
+ pub ( crate ) day : Option < Days > ,
53
+
54
+ #[ command( flatten) ]
55
+ pub ( crate ) week : Week ,
56
+ }
57
+
30
58
#[ derive( Debug , Clone , clap:: ValueEnum ) ]
31
59
pub ( crate ) enum Format {
32
60
Json ,
@@ -74,52 +102,20 @@ pub enum Command {
74
102
/// Number of hours to set
75
103
hours : f32 ,
76
104
77
- /// Name of the job
78
- #[ arg( long, short) ]
79
- job : String ,
80
-
81
- /// Name of the task
82
- #[ arg( long, short) ]
83
- task : String ,
84
-
85
- /// Day(s) of the week, for example "tuesday"
86
- ///
87
- /// Defaults to today if omitted
88
- ///
89
- /// You can also specify multiple days, and/or a range of days, for example
90
- /// "monday-tuesday, friday"
91
- ///
92
- /// Also accepts short day names like "mon", "tue", etc.
93
- #[ arg( long, short, value_parser = parse_days_of_week) ]
94
- day : Option < Days > ,
105
+ #[ command( flatten) ]
106
+ task : Task ,
95
107
96
108
#[ command( flatten) ]
97
- week : Week ,
109
+ day : Day ,
98
110
} ,
99
111
100
112
/// Remove hours on day(s) for a given job and task
101
113
Clear {
102
- /// Name of the job
103
- #[ arg( long, short) ]
104
- job : String ,
105
-
106
- /// Name of the task
107
- #[ arg( long, short) ]
108
- task : String ,
109
-
110
- /// Day(s) of the week, for example "tuesday"
111
- ///
112
- /// Defaults to today if omitted
113
- ///
114
- /// You can also specify multiple days, and/or a range of days, for example
115
- /// "monday-tuesday, friday"
116
- ///
117
- /// Also accepts short day names like "mon", "tue", etc.
118
- #[ arg( long, short, value_parser = parse_days_of_week) ]
119
- day : Option < Days > ,
114
+ #[ command( flatten) ]
115
+ task : Task ,
120
116
121
117
#[ command( flatten) ]
122
- week : Week ,
118
+ day : Day ,
123
119
} ,
124
120
125
121
/// Submit time sheet for week
0 commit comments