Skip to content

Commit

Permalink
Improve --help
Browse files Browse the repository at this point in the history
  • Loading branch information
mawkler committed Nov 13, 2024
1 parent 3995d83 commit 18250d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
30 changes: 14 additions & 16 deletions src/cli/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,25 @@ pub enum Line {
Delete {
line_number: LineNumber,

/// Week number
/// Week number (defaults to current week if omitted)
#[arg(long, short)]
week: Option<u8>,

/// Year
/// Year (defaults to current year if omitted)
#[arg(long, short, requires = "week")]
year: Option<i32>,

},
}

#[derive(Debug, Subcommand)]
pub enum Command {
/// Get the time sheet for the current week
Get {
/// Week number
/// Week number (defaults to current week if omitted)
#[arg(long, short)]
week: Option<u8>,

/// Year
/// Year (defaults to current year if omitted)
#[arg(long, short, requires = "week")]
year: Option<i32>,

Expand All @@ -62,14 +61,6 @@ pub enum Command {
/// Number of hours to set
hours: f32,

/// Week number
#[arg(long, short)]
week: Option<u8>,

/// Year
#[arg(long, short, requires = "week")]
year: Option<i32>,

/// Name of the job
#[arg(long, short)]
job: String,
Expand All @@ -88,6 +79,14 @@ pub enum Command {
/// Also accepts short day names like "mon", "tue", etc.
#[arg(long, short, value_parser = parse_days_of_week)]
day: Option<Days>,

/// Week number (defaults to current week if omitted)
#[arg(long, short)]
week: Option<u8>,

/// Year (defaults to current year if omitted)
#[arg(long, short, requires = "week")]
year: Option<i32>,
},

/// Remove hours hours on day(s) for a given job and task
Expand All @@ -111,14 +110,13 @@ pub enum Command {
#[arg(long, short, value_parser = parse_days_of_week)]
day: Option<Days>,

/// Week number
/// Week number (defaults to current week if omitted)
#[arg(long, short)]
week: Option<u8>,

/// Year
/// Year (defaults to current year if omitted)
#[arg(long, short, requires = "week")]
year: Option<i32>,

},

/// Submit time sheet for week
Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,22 @@ async fn main() -> anyhow::Result<()> {
Command::Get { week, year, format } => command_client.get(week, year, format).await,
Command::Set {
hours,
job,
task,
day,
week,
year,
job,
task,
} => {
command_client
.set(hours, day, week, year, &job, &task)
.await
}
Command::Clear {
job,
task,
day,
week,
year,
job,
task,
} => command_client.clear(&job, &task, day, week, year).await,
// TODO: haven't actually tested this yet (can only be tested once a week)
Command::Submit => command_client.submit().await,
Expand Down

0 comments on commit 18250d6

Please sign in to comment.